Oracle

無法刪除 UNDO TABLESPACE

  • November 15, 2016

我們在兩台不同的伺服器上有 Oracle 11gR1 RAC 兩個實例,新的 undo 表空間UNDOTBS20140508創建了 30G,我想刪除舊的UNDOTBSX02,我做了以下操作:

CREATE UNDO TABLESPACE UNDOTBS20140508  DATAFILE '+DATA/....../UNDOTBS20140508' SIZE 20G;
ALTER SYSTEM SET UNDO_TABLESPACE = UNDOTBS20140508;
DROP TABLESPACE UNDOTBSX02 INCLUDING CONTENTS AND DATAFILES;

嘗試刪除UNDOTBSX02時,它顯示以下錯誤:

Error starting at line : 13 in command -
DROP TABLESPACE UNDOTBSX02 INCLUDING CONTENTS AND DATAFILES
Error report -
SQL Error: ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 57
ORA-30013: undo tablespace 'UNDOTBSX02' is currently in use
00604. 00000 -  "error occurred at recursive SQL level %s"
*Cause:    An error occurred while processing a recursive SQL statement
           (a statement applying to internal dictionary tables).
*Action:   If the situation described in the next error on the stack
           can be corrected, do so; otherwise contact Oracle Support.

我檢查了UNDOTBSX02是否有任何待處理的交易,它是空的。那麼如何放下呢?

注意:我不是 Oracle DBA,但我必須完成這項任務。

上面的建議我都試過了,還是不行,比如select SQL沒有得到結果,還是不能drop undo表空間。根本問題是舊的undo表空間仍然在Oracle中註冊為它的undo,因此我們需要將其更改為新的undo表空間。

以下是我所做的並且有效:

  1. 創建一個新的UNDO表空間:
CREATE SMALLFILE UNDO TABLESPACE "UNDO" 
DATAFILE '+DATA/t2/datafile/undo_01.dbf' SIZE 10G 
REUSE AUTOEXTEND ON NEXT 500M MAXSIZE 10G;
  1. 將新的 UNDO 切換到“官方”的 undo 表空間:
alter system set undo_tablespace='UNDO' scope=both;
  1. 刪除舊的 undo 表空間:
DROP TABLESPACE UNDOTBS1 INCLUDING CONTENTS AND DATAFILES;

希望這可以幫助。

錯誤消息表示tablespace正在使用中,並且由於撤消tablespace至關重要tablespace,因此您需要先使用以下方法將其關閉:

SELECT a.name,b.status , d.username , d.sid , d.serial#
FROM   v$rollname a,v$rollstat b, v$transaction c , v$session d
WHERE  a.usn = b.usn
AND    a.usn = c.xidusn
AND    c.ses_addr = d.saddr
AND    a.name IN ( 
         SELECT segment_name
         FROM dba_segments 
         WHERE tablespace_name = 'UNDOTBSX02'
        ); 

然後通過使用殺死撤消表空間的 SID

alter system kill session 'SID,serial'; --change the values of sid and serial by the ones  that being retrived from the previouse command

現在你應該可以放下它了。

引用自:https://dba.stackexchange.com/questions/65099