【正文】
行 imp的用戶 */ Import 舉例 ? 對特定用戶選擇表的數(shù)據(jù)裝載 imp system/manager file= fromuser=scott tables= (dept,emp) ? 裝載從另外用戶中卸載的表 imp scott/tiger fromuser=blake touser=scott file= tables=(unit,manager) ? 裝載從一個(gè)用戶到另外一個(gè)用戶的表 imp system/manager file= fromuser=scott touser=blake tables=(*) ? Oracle 數(shù)據(jù)庫的備份與恢復(fù) –數(shù)據(jù)庫備份 –數(shù)據(jù)庫例程失敗的恢復(fù) –介質(zhì)故障的恢復(fù) 備份方式 ? 物理備份 就是 Oracle的數(shù)據(jù)文件通過操作系統(tǒng)的工具進(jìn)行的 備份。定義你需要卸載數(shù)據(jù)的用戶。 ? Import – 它將讀取轉(zhuǎn)出的數(shù)據(jù)將重建數(shù)據(jù)庫的內(nèi)容與結(jié)構(gòu)。視圖 dbacolprivs。 rolename privelege...... 常用的幾個(gè)角色 role (權(quán)限的集合 ) connect (8) 連上 Oracle,做最基本操作 resource(5) 具有程序開發(fā)最基本的權(quán)限 dba (77)數(shù)據(jù)庫管理員所有權(quán)限 expfulldatabase 可把數(shù)據(jù)庫整個(gè)備份輸出的 權(quán)限 impfulldatsabase 可把數(shù)據(jù)庫整個(gè)備份恢復(fù)輸 入的權(quán)限 (3)alter user。 刪除回滾段 ?DROP ROLLBACK SEGMENT rbs01。 使回滾段 ONLINE ?ALTER ROLLBACK SEGMENT rbs01 ONLINE。 下述命令刪除 APP_DATA表空間及其 中的內(nèi)容 . 獲取表空間有關(guān)的信息 DBA_TABLESPACES ? TABLESPACE_NAME ? NEXT_EXTENT ? MAX_EXTENTS ? PCT_INCREASE ? MIN_EXTLEN ? STATUS ? CONTENTS 獲取數(shù)據(jù)文件有關(guān)的信息 ?DBA_DATA_FILES ? FILE_NAME ? TABLESPACE_NAME ? BYTES ? AUTOEXTENSIBLE ? MAXBYTES ? INCREMENT_BY 一般原則 ? 使用多個(gè)表空間 ? 為表空間指定存儲(chǔ)參數(shù) ? 給用戶指定表空間限額 回滾段的管理 課程目標(biāo) –回滾段個(gè)數(shù)和大小的規(guī)劃 – 使用合適的存儲(chǔ)參數(shù)建立回滾段 –回滾段的維護(hù) –從數(shù)據(jù)字典中獲取回滾段的信息 –回滾段問題的診斷 回滾段的類型 – SYSTEM –非 SYSTEM ? 私用 ? 公用 事物和回滾段 回滾段的增長 讀一致性 介紹回退段的有關(guān)概念 回滾段的回縮 回滾段個(gè)數(shù)的規(guī)劃 – OLTP ? 多個(gè)小的回滾段 ? 每個(gè)回滾段四個(gè)事物 ? 《 = N/4 – Batch ? 少量的大回滾段 回滾段個(gè)數(shù)的規(guī)劃 –查詢是否有回滾段的競爭 – SVRMGR select * from v$waitstat。 ALTER TABLESPACE app_data DEFAULT STORAGE (INITIAL 2M NEXT 2M MAXEXTENTS 999)。 存儲(chǔ)參數(shù) 下述參數(shù)影響段的空間分配 : – INITIAL – NEXT – MAXEXTENTS – MINEXTENTS – PCTINCREASE 表空間管理的一般原則 使用同樣大小的子段 只在表空間上指定存儲(chǔ)參數(shù) 子段大小為 160K, 5120KB, 160MB 監(jiān)視子段個(gè)數(shù)超過 1024的段 非常大的表應(yīng)單獨(dú)建立表空間 TEMP段應(yīng)放在 TEMP表空間 回滾段應(yīng)單獨(dú)放在回滾段的表空間 給表空間增加數(shù)據(jù)文件 ALTER TABLESPACE APP_data ADD DATAFILE ?DISK5/?SIZE 200M。 Quick Reference 管理控制文件 課程目標(biāo) ? 解釋控制文件的使用 ? 了解控制文件的內(nèi)容 ? 獲取控制文件信息 ? 復(fù)用控制文件 控制文件的作用 是小的二進(jìn)制文件,在 : 數(shù)據(jù)庫 MOUNT 數(shù)據(jù)庫運(yùn)行需要使用。 sqlplus scott/tiger sql /* sql*plus的命令行狀態(tài) */ sql set pause on spool filename spool off 維護(hù)參數(shù)文件( ) Managing an Oracle Instance Uses of Parameters – The parameter file, monly referred to as the init file, is a text file that can be maintained using a standard operating system editor. By default, it is located in the %ORACLE_HOME%\database directory on Windows NT. With Oracle8i on Windows NT, the parameter file points to the %ORACLE_HOME%\admin\ sid \pfile directory where the actual parameter file is stored. The parameters in the init file can have a significant effect on database performance, and some need to be modified in the following ways for production systems: ? Size the System Global Area (SGA). ? Set database and instance defaults. ? Set user or process limits. ? Set limits on database resources. ? Define various physical attributes of the database,such as the database block size. ? Specify control files, archived log files, the ALERT file, and trace file locations. Rules for Specifying Parameters ? Specify the values in the following format: keyword=value. ? All parameters are optional. ? The server has a default value for each parameter. This value may be operating system dependent, depending on the parameter. ? Parameters can be specified in any order. ? Comment lines begin with the symbol. ? Enclose parameters in double quotation marks to include character literals. ? Additional files can be included with the keyword IFILE. ? If case is significant for the operating system, then it is also significant in filenames. ? Multiple values are enclosed in parentheses and separated by mas. Note: Develop a standard for listing parameters。 ? DML – update(改變表與視圖現(xiàn)有行與列的值 ) update emp set sal=1000 where empno=7369。 – Order by select ename ,deptno,sal from emp order by deptno ASC,sal DESC。甚至通過 PL*SQL語言還可以開發(fā)基于 Web的應(yīng)用。 ? Oracle的 SQL語言分為以下幾類: – DML(數(shù)據(jù)操縱語言) – DDL(數(shù)據(jù)定義語言) – 事物處理的控制語言 – 會(huì)話控制語句 – 系統(tǒng)控制語句 – SQL*PLUS ? 是 Oracle的一個(gè)使用程序,它可以運(yùn)行于客戶端,也可以運(yùn)行 服務(wù)器端,通過它能夠查看數(shù)據(jù)字典的信息,以及查看用戶數(shù)據(jù)和結(jié)構(gòu)等,運(yùn)行程序。 任何 Oracle用戶都不能改變數(shù)據(jù)字典的任何數(shù)據(jù)。 備注: SQL語句大小寫敏感的,同樣的一個(gè)語句,若大小寫不同, oracle需分析執(zhí)行兩次,每句后必以“;”結(jié)束。 SCN自動(dòng)增加,在數(shù)據(jù)庫是唯一的。 3 用戶被通知 COMMIT完成。與 SGA不同, PGA僅被一個(gè)進(jìn)程使用。在數(shù)據(jù)緩存永久寫入數(shù)據(jù)庫時(shí)。 Background Processes – ? Database Writer (DBW0) 負(fù)責(zé)將數(shù)據(jù)的更改由 database buffer cache寫到 data files 。 ? 重作日志緩沖區(qū) ( redo log buffer)用來記錄服務(wù)或后臺(tái)進(jìn)程對數(shù)據(jù)庫的操作 。分配在 Oracle Server駐留的計(jì)算機(jī)虛擬內(nèi)存中。 Oracle InstanceSGA Oracle instance 包含 SGA內(nèi)存結(jié)構(gòu)和管理數(shù)據(jù)庫的一些后臺(tái)進(jìn)程。 ? 一個(gè) data block對應(yīng)一個(gè)或多個(gè)分配給 data file的操作系統(tǒng)塊。 – DBA可以手工為 segment 增加 extents 。 ? 每個(gè) segment 有一個(gè)或多個(gè) extent 組成。 段 Segments Segment指在 tablespace中為特定邏輯存儲(chǔ)結(jié)構(gòu)分配的空間。這些物理結(jié)構(gòu)在 oracle服務(wù)運(yùn)行時(shí)與操作系統(tǒng)相配合。 – 每個(gè) tablespace 包含一個(gè)或多個(gè)操作系統(tǒng)文件-數(shù)據(jù)文件 (data files). – 一個(gè) tablespace 可能包含一個(gè)或多個(gè) segments. – Tablespaces 可以在數(shù)據(jù)庫運(yùn)行時(shí)使其在線。 – 口令驗(yàn)證文件 用來驗(yàn)證啟動(dòng)和關(guān)閉 Oracle實(shí)例的用戶。例如:控制文件用來檢驗(yàn)數(shù)據(jù)文件和重作日志文件。 –當(dāng)數(shù)據(jù)庫空間不足時(shí),數(shù)據(jù)文件具有自動(dòng)擴(kuò)展的特性。 物理結(jié)構(gòu)指數(shù)據(jù)庫中的操作系統(tǒng)文件的集合,包含以下三種文件: ? 數(shù)據(jù)文件 (data file) 包含數(shù)據(jù)庫中實(shí)際數(shù)據(jù)。 Oracle服務(wù) (server)是一個(gè)關(guān)系數(shù)據(jù)庫 (relational database)管理系統(tǒng),提供開放、全面、完整的信息管理 。數(shù)據(jù)庫、電子商務(wù)套件、 erp、財(cái)務(wù)產(chǎn)品、開發(fā)工具培訓(xùn)認(rèn)證。 Oracle 數(shù)據(jù)庫可以分為 邏輯 (logical)結(jié)構(gòu)和物理 (physical)結(jié)構(gòu) 。數(shù)據(jù)文件的特性有: – 一個(gè)數(shù)據(jù)文件只能被一個(gè)數(shù)據(jù)庫使用。 ? 控制文件 (Control files) 包含維護(hù)和檢驗(yàn)數(shù)據(jù)庫一致性的信息。例如:他包含 SGA內(nèi)存的大小。 – An Oracle database can be logically grouped into smaller logical areas of space known as tablespaces. – 一個(gè) tablespace 只能同時(shí)屬于一個(gè) database。 Database Architecture (Continued) 數(shù)據(jù)文件 Data Files Oracle數(shù)據(jù)庫 tablespace包含的一個(gè)或多個(gè)文件叫做數(shù)據(jù)文件 (data files)。 ?數(shù)據(jù)庫管理員在數(shù)據(jù)文件創(chuàng)建后可以改變它的大小或者設(shè)置為根據(jù)需要自動(dòng)增長。 但是 , 一個(gè) segment 可以跨越多個(gè)屬于同一 Tablespace 的 data files 。 – 當(dāng) segment增長時(shí), extents被加到 segment 中。 The Relationships Among Segments, Extents, and Data