標籤:oracle 空間 學習計劃 system 意志力
今天是2016年4月5號,之前制定的學習計劃一直沒有執行,發現自己還是一個意志力很薄弱的人!今後不管工作多忙,都希望自己能把學習計劃堅持下去,用放空的心態去重新學習oracle!加油! 今天打算重新過一遍oracle資料表空間管理,雖然我是做oracle開發的,但是我還是有一顆走向DBA的心!oracle磁碟空間管理中的最高邏輯層就是資料表空間,下一層是段,一個段只能駐留在一個資料表空間裡面,段的下一層是盤區,多個盤區組組成一個段,下一層就是資料區塊,也就是最底層啦~1:查看錶空間的相關資訊select tablespace_name,file_name,bytes from dba_data_files order by tablespace_name;2:oracle預設資料表空間SYSAUX:system資料表空間的輔助資料表空間,儲存除了資料字典以外的其他資料對象,減少system空間負荷SYYTEM:存放資料字典,表、視圖、預存程序的定義等TEMP:存放SQL語句處理的表和索引的資訊UNDOTBS1:存放撤銷資料的資料表空間USERS;通常存放應用系統所使用的資料對象查看錶空間裡面存放的資料物件類型和擁有著select segment_type,segment_name,owner from dba_segments from tablespace_name=‘USERS‘;3:建立資料表空間在建立資料表空間的時候需要考慮以下幾點1 建立小檔案資料表空間,還是大檔案資料表空間2 是局部盤區管理方式,還是傳統的目錄盤區管理方式3 手動管理資料表空間 還是自動拓展資料表空間4 是否用於零時段或者撤銷段的特殊資料表空間create tableaspace table_name datafile ‘\data\table_name.dbf‘ size 10M(大小) extent management local(預設的就是本地化管理) uniform size 256k 建立大檔案資料表空間create bigfile tablespace name datafile ‘\data\name.dbf‘ size 2G;資料表空間維護1:查看預設資料表空間SELECT PROPERTY_VALUE, PROPERTY_NAME FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME LIKE ‘%TABLESPACE‘;2:更改預設資料表空間alter database default temprory tablespace temp_name;alter database default tablespace temp_name;3:更改資料表空間狀態alter tablespace tablespace_name read only/write(唯讀\可讀寫)重新命名alter tablespace name1 rename to name2;刪除資料表空間drop tablespace name1 including contents(同時刪除資料) cascade constraints (刪除相關約束)4:維護資料表空間資料檔案添加資料檔案alter tablespace tablespace_name add datafile ‘/data/name2.dbf‘ aize 10M autoextend on next 5M maxsize unlimited;(自動拓展,最大不受限制)刪除檔案alter tablespace tablespace_name drop datafile ‘/data/name2.dbf‘;5:管理撤銷資料表空間介紹:撤銷資料表空間用於存放撤銷資訊,當執行DML操作的時候 oracle會將就資料寫到UNDO段裡面而UNDO段駐留在UNDO資料表空間中作用:讀寫一致、復原事務、事務恢複、閃回操作。撤銷資料表空間的初始化參數1:UNDO_TABLESPACE: 指定常式所要使用的UNDO資料表空間2:UNDO_MANAGEMENT: 制定UNDO資料的管理員模式 為AUTO就是自動撤銷管理員模式 MANUAL為復原段管理方式UNDO_RETENTION 資料最大保留時間 900S 建立UNDO資料表空間create undo tablespace undo_name datafile ‘/data/name.dbf‘ size 1G;添加檔案alter tablespace undo_name add datafile ‘/data/name2.dbf‘;切換UNDO資料表空間alter system set undo_tablespcae=undo_name;刪除drop tablespace undo_name;undo查詢操作(1)當前常式正在使用的UNDO空間show parameter undo_tablespace;(2) 執行個體的所有UNDO資料表空間select tablespace_name from dba_tablespace where contents=‘UNDO‘;(3) 查看UNDO資料表空間的統計資訊select to_char(begin_time,‘hh24:mi:ss‘) as 開始時間,to_char(end_time,‘hh24:mi:ss‘) as 結束時間,undoblks as 回退塊數 from v$undostat order by begin_time;6:管理暫存資料表空間查詢暫存資料表空間資訊select file_name,bytes,tablespace_name from dba_temp_files;建立暫存資料表空間組create temporary tablespace tp1 tempfile ‘/data/temp1.dbf‘ size 10m tablespace group group1;create temporary tablespace tp2 tempfile ‘/data/temp2.dbf‘ size 10m tablespace group group1;轉移到另外一個組alter tablespace tp1 tablespace group group3;把暫存資料表空間分配給指定使用者alter user name temporary tablespace group3;設定預設暫存資料表空間組alter database orcl default temporary tablespace group3;刪除drop tablespace tp1 including contents and datafile;
oracle資料表空間管理