Oracle裏的回滾表空間在數據庫使用一段時間後,undo表空間的dbf文件每每會增加到比較大,這個時候咱們須要切換undo表空間數據庫
1.新建undo表空間spa
SQL> create undo tablespace undotbs2 datafile '/data/undotbs02.dbf' size 10M autoextend on next 10M ;get
2.因爲undo_tablespace是個動態參數,因此任什麼時候候均可以set。string
SQL> alter system set undo_tablespace='undotbs2' scope=both; io
系統已更改。 table
3.查看原來的undo表空間中的undo segment是否都爲offlinefile
SQL> select tablespace_name,segment_name,status from dba_rollback_segs; select
TABLESPACE_NAME SEGMENT_NAME STATUS next
------------------------------ ------------------------------ ---------------- 數據
SYSTEM SYSTEM ONLINE
UNDOTBS1 _SYSSMU1$ OFFLINE
UNDOTBS1 _SYSSMU2$ OFFLINE
UNDOTBS1 _SYSSMU3$ OFFLINE
UNDOTBS1 _SYSSMU4$ OFFLINE
UNDOTBS1 _SYSSMU5$ OFFLINE
UNDOTBS1 _SYSSMU6$ OFFLINE
UNDOTBS1 _SYSSMU7$ OFFLINE
UNDOTBS1 _SYSSMU8$ OFFLINE
UNDOTBS1 _SYSSMU9$ OFFLINE
UNDOTBS1 _SYSSMU10$ OFFLINE
UNDOTBS2 _SYSSMU11$ ONLINE
UNDOTBS2 _SYSSMU12$ ONLINE
UNDOTBS2 _SYSSMU13$ ONLINE
UNDOTBS2 _SYSSMU14$ ONLINE
UNDOTBS2 _SYSSMU15$ ONLINE
UNDOTBS2 _SYSSMU16$ ONLINE
UNDOTBS2 _SYSSMU17$ ONLINE
UNDOTBS2 _SYSSMU18$ ONLINE
UNDOTBS2 _SYSSMU19$ ONLINE
TABLESPACE_NAME SEGMENT_NAME STATUS
------------------------------ ------------------------------ ----------------
UNDOTBS2 _SYSSMU20$ ONLINE
21 rows selected www.2cto.com
原來undotbs1的undo_segment 都爲offline,則能夠刪除undotbs1.
SQL> alter tablespace undotbs1 offline;
SQL> drop tablespace undotbs1 including contents and datafiles;
表空間已刪除。
再次查看:
SQL> select tablespace_name,segment_name,status from dba_rollback_segs;
TABLESPACE_NAME SEGMENT_NAME STATUS
------------------------------ ------------------------------ ----------------
SYSTEM SYSTEM ONLINE
UNDOTBS2 _SYSSMU11$ ONLINE
UNDOTBS2 _SYSSMU12$ ONLINE
UNDOTBS2 _SYSSMU13$ ONLINE
UNDOTBS2 _SYSSMU14$ ONLINE
UNDOTBS2 _SYSSMU15$ ONLINE
UNDOTBS2 _SYSSMU16$ ONLINE
UNDOTBS2 _SYSSMU17$ ONLINE
UNDOTBS2 _SYSSMU18$ ONLINE
UNDOTBS2 _SYSSMU19$ ONLINE
UNDOTBS2 _SYSSMU20$ ONLINE
11 rows selected www.2cto.com
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string undotbs1
--EOF