【正文】
–表空間 offline時出錯 空間不夠 –表空間中無空閑空間 ? 增大文件 ? 允許文件自動擴充 ? 增加文件 –達到段的 MAXEXTENTS ? 增大 MAXEXTENTS ? 用更大的子段參數(shù)重建回滾段 用戶管理 創(chuàng)建、改變、刪除和監(jiān)控 oracle的新用戶 用戶管理 (1)賦于合法的用戶或和密碼 SVRMGLCREATE USER username IDENTIFIED BY userpassword [DEFAULT TABLESPACE tablespace1] [TEMPORARY TABLESPACE tablespace2] [QUOTA n K ON tablespace1]。 刪除回滾段 ?DROP ROLLBACK SEGMENT rbs01。 ?使用 ALTER ROLLBACK SEGMENT命令 從回滾段中釋放空間 ?ALTER ROLLBACK SEGMENT rbs01 ?SHRINK TO 4M。 使回滾段 ONLINE ?ALTER ROLLBACK SEGMENT rbs01 ONLINE。 – MINEXTENTS設(shè)為 20 – OPTIMAL 應(yīng)大于 MINTEXTENTS的大小 – INITIAL=NEXT=1。 下述命令刪除 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 一般原則 ? 使用多個表空間 ? 為表空間指定存儲參數(shù) ? 給用戶指定表空間限額 回滾段的管理 課程目標(biāo) –回滾段個數(shù)和大小的規(guī)劃 – 使用合適的存儲參數(shù)建立回滾段 –回滾段的維護 –從數(shù)據(jù)字典中獲取回滾段的信息 –回滾段問題的診斷 回滾段的類型 – SYSTEM –非 SYSTEM ? 私用 ? 公用 事物和回滾段 回滾段的增長 讀一致性 介紹回退段的有關(guān)概念 回滾段的回縮 回滾段個數(shù)的規(guī)劃 – OLTP ? 多個小的回滾段 ? 每個回滾段四個事物 ? 《 = N/4 – Batch ? 少量的大回滾段 回滾段個數(shù)的規(guī)劃 –查詢是否有回滾段的競爭 – SVRMGR select * from v$waitstat。 移動數(shù)據(jù)文件 表空間 APP_DATA 必須 OFFLINE 目標(biāo)文件必須存在 ALTER TABLESPACE app_data RENAME DATAFILE ?DISK4/?TO ?DISK5/? 只讀表空間 ALTER TABLESPACE app_data READ ONLY。 ALTER TABLESPACE app_data DEFAULT STORAGE (INITIAL 2M NEXT 2M MAXEXTENTS 999)。 Tablespace APP_ DATA ?ALTER DATABASE DATAFILE ?DISK5/?RESIZE 200M。 存儲參數(shù) 下述參數(shù)影響段的空間分配 : – INITIAL – NEXT – MAXEXTENTS – MINEXTENTS – PCTINCREASE 表空間管理的一般原則 使用同樣大小的子段 只在表空間上指定存儲參數(shù) 子段大小為 160K, 5120KB, 160MB 監(jiān)視子段個數(shù)超過 1024的段 非常大的表應(yīng)單獨建立表空間 TEMP段應(yīng)放在 TEMP表空間 回滾段應(yīng)單獨放在回滾段的表空間 給表空間增加數(shù)據(jù)文件 ALTER TABLESPACE APP_data ADD DATAFILE ?DISK5/?SIZE 200M。 回滾表空間 用于 保存回滾段 不 要包含其他永久性數(shù)據(jù) CREATE TABLESPACE rbs DATAFILE ?DISK2/?SIZE 50M MINIMUM EXTENT 1M DEFAULT STORAGE (INITIAL 2M NEXT 2M MAXEXTENTS 500 PCTINCREASE 0) 。 Quick Reference 管理控制文件 課程目標(biāo) ? 解釋控制文件的使用 ? 了解控制文件的內(nèi)容 ? 獲取控制文件信息 ? 復(fù)用控制文件 控制文件的作用 是小的二進制文件,在 : 數(shù)據(jù)庫 MOUNT 數(shù)據(jù)庫運行需要使用。 this allows any valid user to connect to the database and perform typical data access operations. Opening the database includes the following tasks: ? Opening the online data files ? Opening the online redo log files If any of the data files or online redo log files are not present when you attempt to open the database, the Oracle server returns an error. During this final stage, the Oracle server verifies that all the data files and online redo log files can be opened and checks the consistency of the database. If necessary, the System Monitor background process (SMON) initiates instance recovery. Starting Up To start up an instance, use the following mand: STARTUP [FORCE] [RESTRICT] [PFILE= filename] [OPEN [RECOVER][ database] |MOUNT |NOMOUNT] To open the database from STARTUP NOMOUNT to a MOUNT stage or from MOUNT to an OPEN stage, use the ALTER DATABASE mand: ALTER DATABASE { MOUNT | OPEN } ALTER DATABASE OPEN [READ WRITE| READ ONLY] Example: – Start up the instance and open the database: STARTUP PFILE=/DISK1/initU15. – Change the state of the database from NOMOUNT to MOUNT: ALTER DATABASE database MOUNT。 sqlplus scott/tiger sql /* sql*plus的命令行狀態(tài) */ sql set pause on spool filename spool off 維護參數(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。 – delete (從表與視圖中刪除行 ) delete from emp where deptno=10。 ? DML – update(改變表與視圖現(xiàn)有行與列的值 ) update emp set sal=1000 where empno=7369。 select empno,sal,m from emp,dept where job=‘ CLERK’ and = and loc=‘ NEW YORK’ for update of 。 – Order by select ename ,deptno,sal from emp order by deptno ASC,sal DESC。 ? 復(fù)雜的 select 語句: – group by 子句 select deptno,min(sal),max(sal) from emp group by deptno。甚至通過 PL*SQL語言還可以開發(fā)基于 Web的應(yīng)用。他有自己的程序結(jié)構(gòu), 有各種條件控制和循環(huán)控制。 ? Oracle的 SQL語言分為以下幾類: – DML(數(shù)據(jù)操縱語言) – DDL(數(shù)據(jù)定義語言) – 事物處理的控制語言 – 會話控制語句 – 系統(tǒng)控制語句 – SQL*PLUS ? 是 Oracle的一個使用程序,它可以運行于客戶端,也可以運行 服務(wù)器端,通過它能夠查看