表和用戶已經刪除,但是數據文件的空間沒有釋放

今天在自己的實驗環境上建了一個用戶test,在此用戶下建立了50多張表並插入了海量數據,最後發現磁盤空間幾乎沾滿,想做別的實驗已經不可能,於是刪除了用戶test,使用關鍵詞cascade刪除的,但是最後發現用戶雖然刪除了,但是數據文件的大小依然沒有變化,並且發現有大量的undo日誌,undo表空間異常的大,怎麼解決次問題呢???

解決思路:

查看

undo數據文件太大希望重建undo表空間,並且通過alter  database  datafile  'users01.dbf' resize ...修改數據文件的大小

在執行的時候遇到了問題:

問題:undo表空間不能刪除

SQL> showparameter undo

 

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

undo_management                      string      AUTO

undo_retention                       integer     900

undo_tablespace                      string      UNDOTBS1

SQL> create undotablespace undotbs2 datafile '/u01/app/oracle/oradata/dsg01/undotbs201.dbf'size 300M;

 

表空間已創建。

 

SQL> alter systemset undo_tblespace=undotbs2;

alter system setundo_tblespace=undotbs2

                 *

第 1 行出現錯誤:

ORA-02065: 非法的 ALTER SYSTEM 選項

 

 

SQL> alter systemset undo_tablespace=undotbs2;

 

系統已更改。

 

SQL> showparameter undo

 

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

undo_management                      string      AUTO

undo_retention                       integer     900

undo_tablespace                      string      UNDOTBS2

SQL>

SQL>

SQL>

SQL> droptablespace undotbs1;

drop tablespaceundotbs1

*

第 1 行出現錯誤:

ORA-30013: 還原表空間 'UNDOTBS1' 當前正在使用中

 

 

SQL> alter systemswitch logfile;

 

系統已更改。

 

SQL> droptablespace undotbs1;

drop tablespaceundotbs1

*

第 1 行出現錯誤:

ORA-30013: 還原表空間 'UNDOTBS1' 當前正在使用中

 

 

SQL> !oerr ora30013

30013, 00000,"undo tablespace '%s' is currently in use"

// *Cause:   the specified undo tablespace is currentlyused by another

//           instance.

// *Action:  Wait for the undo tablespace to becomeavailable or

//           change to another name and reissuethe statement.

 

SQL> alter systemcheckpoint;

 

系統已更改。

 

SQL> droptablespace undotbs1;

drop tablespaceundotbs1

*

第 1 行出現錯誤:

ORA-30013: 還原表空間 'UNDOTBS1' 當前正在使用中

 

 

SQL> ^C

 

SQL>

SQL>

SQL> showparameter undo

 

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

undo_management                      string      AUTO

undo_retention                       integer     900

undo_tablespace                      string      UNDOTBS2

SQL> droptablespace undotbs1;

drop tablespaceundotbs1

*

第 1 行出現錯誤:

ORA-30013: 還原表空間 'UNDOTBS1' 當前正在使用中

 

 

SQL> altertablespace undotbs1 offline;

alter tablespaceundotbs1 offline

*

第 1 行出現錯誤:

ORA-30042:無法使還原表空間脫機

 

分析:undotbs1表空間中有未處理完成的事務,那麼怎麼處理未完成的事務呢?

什麼不能將undotbs1置爲offline呢,原因當你切換tablespace後,新的事務都會使用新的untotbs,而老的事務仍然在用着老的空間,等所有老的事務都提交後(一般需要等待十分鐘,你再進行置爲offline即可),就你可以將老的undotbs1置爲offline.

SQL> altertablespace undotbs1 offline;

 

表空間已更改。

 

SQL> droptablespace undotbs1 including contents and datafiles;

 

表空間已刪除。

 

(2)重置永久表空間的大小

SQL> alter database datafile '/u01/app/oracle/oradata/dsg01/users01.dbf' resize 500M;
alter database datafile '/u01/app/oracle/oradata/dsg01/users01.dbf' resize 500M
*
第 1 行出現錯誤:
ORA-03297: 文件包含在請求的 RESIZE 值以外使用的數據


SQL> alter database datafile '/u01/app/oracle/oradata/dsg01/users01.dbf' resize 700M;

數據庫已更改。

發佈了111 篇原創文章 · 獲贊 32 · 訪問量 38萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章