【正文】
? 選擇合適的 PCTFREE和 PCTUSED建表參數(shù) ? 選擇合適的 initial和 next存儲(chǔ)空間分配參數(shù) ? 用 press方式 Export/Import數(shù)據(jù) 數(shù)據(jù)庫(kù)性能調(diào)整 收集統(tǒng)計(jì)數(shù)據(jù) ? 對(duì)于數(shù)據(jù)表 ? analyze table 表名 estimate statistics sample 20 percent。 Oracle 數(shù)據(jù)庫(kù)的備份與恢復(fù) ? 介質(zhì)故障的恢復(fù) – 在應(yīng)用讀寫數(shù)據(jù)庫(kù)文件時(shí),可能發(fā)生錯(cuò)誤。 先恢復(fù)第十天的數(shù)據(jù) 再做全數(shù)據(jù)庫(kù)備份的恢復(fù)(第一天) 再做第一次累計(jì)備份文件的恢復(fù)(第五天) 再做最后一次累計(jì)備份文件的恢復(fù)(第八天) 在依此做第九天,第十天的增量恢復(fù)。 冷備份 ? 定義: – 在數(shù)據(jù)庫(kù)系統(tǒng)正常關(guān)閉的情況下,通過操作系統(tǒng)的命令將所有相關(guān)的數(shù)據(jù)庫(kù)文件拷貝進(jìn)行的備份。 在系統(tǒng)發(fā)生故障時(shí)的恢復(fù)工作,需要根據(jù)不同的故障情況,在 oracle工程師的指導(dǎo)下實(shí)現(xiàn)恢復(fù)的工作。 svrmgralter tablespace tablespace_name begin backup。 ? offline 需要備份的 tablespace是離線的。鍵入如下命令: $svrmgrl svrmgrconnect internal。它是決定數(shù)據(jù)的備份級(jí)別是基于全數(shù)據(jù)庫(kù) – grants 決定 export程序是否卸載授權(quán) default=y – owner 決定數(shù)據(jù)卸載的級(jí)別。它 轉(zhuǎn)出的數(shù)據(jù)只有 Oracle的 import程序能夠處理。 M UNLIMITED 空間限額 (2)授于用戶連接 Oracle數(shù)據(jù)庫(kù)的權(quán)限 SVRMGLgrant connect to username [with grant option]。 25M/n 建立回滾段 ?CREATE ROLLBACK SEGMENT rbs01 ?TABLESPACE rbs ?STORAGE ( ?INITIAL 100K NEXT 100K OPTIMAL 4M MINEXTENTS 20 MAXEXTENTS 100)。 手工改變數(shù)據(jù)文件的大小 改變存儲(chǔ)參數(shù) ALTER TABLESPACE app_data MINIMUM EXTENT 2M。 – Open the database as a readonly database: ALTER DATABASE database OPEN READ ONLY。 – join select empno,ename,dname from emp,dept where =。通過PL*SQL語言,能夠?qū)憯?shù)據(jù)庫(kù)的存儲(chǔ)過程和包。 – 包括: ? 數(shù)據(jù)庫(kù)所有對(duì)象的定義(表,視圖,索引,簇,同義詞,序列 ,過程,函數(shù),程序包,觸發(fā)器) ? 空間的分配和使用狀況 ? 列的缺省值 ? 完整性約束信息 ? 用戶名 ? 已授予用戶的角色和權(quán)限 ? 審計(jì)信息等 ? 數(shù)據(jù)字典結(jié)構(gòu) – 基表 ? 存放相關(guān)數(shù)據(jù)庫(kù)信息的基礎(chǔ)表 – 視圖 ? 匯總并顯示存放數(shù)據(jù)字典基表中信息的視圖 ? 數(shù)據(jù)字典所有者 – Oracle的 sys用戶擁有數(shù)據(jù)字典所有的基表和視圖。 System Change Number 無論事務(wù)在何時(shí)提交, Oracle server總是分配一個(gè) System Change Number (SCN)給這個(gè)事務(wù)。當(dāng)用戶連接入 Oracle數(shù)據(jù)庫(kù)并建立會(huì)話時(shí), Oracle分配 PGA。例如:在備份和恢復(fù)時(shí)的數(shù)據(jù)拷貝 。它包含 Oracle Server 數(shù)據(jù)和控制信息。 The Relationships Among Segments, Extents, and Data Blocks Data Blocks Oracle server管理 data files存儲(chǔ)空間的單位叫做 Oracle blocks or data blocks. ? Oracle 數(shù)據(jù)庫(kù)最小的存儲(chǔ)數(shù)據(jù)單位為 data blocks. ? Oracle data blocks是 Oracle server存儲(chǔ)、讀、寫的最小的存儲(chǔ)單位。 但是 , 一個(gè) segment 可以跨越多個(gè)屬于同一 Tablespace 的 data files 。 Database Architecture (Continued) 數(shù)據(jù)文件 Data Files Oracle數(shù)據(jù)庫(kù) tablespace包含的一個(gè)或多個(gè)文件叫做數(shù)據(jù)文件 (data files)。例如:他包含 SGA內(nèi)存的大小。數(shù)據(jù)文件的特性有: – 一個(gè)數(shù)據(jù)文件只能被一個(gè)數(shù)據(jù)庫(kù)使用。數(shù)據(jù)庫(kù)、電子商務(wù)套件、 erp、財(cái)務(wù)產(chǎn)品、開發(fā)工具培訓(xùn)認(rèn)證。 物理結(jié)構(gòu)指數(shù)據(jù)庫(kù)中的操作系統(tǒng)文件的集合,包含以下三種文件: ? 數(shù)據(jù)文件 (data file) 包含數(shù)據(jù)庫(kù)中實(shí)際數(shù)據(jù)。例如:控制文件用來檢驗(yàn)數(shù)據(jù)文件和重作日志文件。 – 每個(gè) tablespace 包含一個(gè)或多個(gè)操作系統(tǒng)文件-數(shù)據(jù)文件 (data files). – 一個(gè) tablespace 可能包含一個(gè)或多個(gè) segments. – Tablespaces 可以在數(shù)據(jù)庫(kù)運(yùn)行時(shí)使其在線。 段 Segments Segment指在 tablespace中為特定邏輯存儲(chǔ)結(jié)構(gòu)分配的空間。 – DBA可以手工為 segment 增加 extents 。 Oracle InstanceSGA Oracle instance 包含 SGA內(nèi)存結(jié)構(gòu)和管理數(shù)據(jù)庫(kù)的一些后臺(tái)進(jìn)程。 ? 重作日志緩沖區(qū) ( redo log buffer)用來記錄服務(wù)或后臺(tái)進(jìn)程對(duì)數(shù)據(jù)庫(kù)的操作 。在數(shù)據(jù)緩存永久寫入數(shù)據(jù)庫(kù)時(shí)。 3 用戶被通知 COMMIT完成。 備注: SQL語句大小寫敏感的,同樣的一個(gè)語句,若大小寫不同, oracle需分析執(zhí)行兩次,每句后必以“;”結(jié)束。 ? 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)行程序。 – Order by select ename ,deptno,sal from emp order by deptno ASC,sal DESC。 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。 存儲(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。 下述命令刪除 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 ? 私用 ? 公用 事物和回滾段 回滾段的增長(zhǎng) 讀一致性 介紹回退段的有關(guān)概念 回滾段的回縮 回滾段個(gè)數(shù)的規(guī)劃 – OLTP ? 多個(gè)小的回滾段 ? 每個(gè)回滾段四個(gè)事物 ? 《 = N/4 – Batch ? 少量的大回滾段 回滾段個(gè)數(shù)的規(guī)劃 –查詢是否有回滾段的競(jìng)爭(zhēng) – SVRMGR select * from v$waitstat。 刪除回滾段 ?DROP ROLLBACK SEGMENT rbs01。視圖 dbacolprivs。定義你需要卸載數(shù)據(jù)的用戶。 $svrmgrl svrmgrconnect