在刪除索引、表、或者資料表空間及使用者等資料庫物件或者使用者的時候,有時候會遇到入下錯誤:
SQL> drop user Oracle cascade;
drop user oracle cascade;
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-02429: cannot drop index used for enforcement of unique/primary key
我們知道drop user 帶cascade會將所屬的資料表空間和其他關聯資料庫物件一起刪除,而這也說明正要被刪除的對象和其他對象之間存在主外鍵約束關聯的問題,所以需要查詢該對象存在哪些約束並刪除之
SQL>select 'alter table '||owner||'.'||table_name||' drop constraint '||constraint_name||' ;'
from dba_constraints
where constraint_type in ('U', 'P')
and (index_owner, index_name) in
(select owner, segment_name
from dba_segments
where onwner = 'ORACLE');
alter table w.table_name drop constraint PK_ID ;
alter table x.table_name drop constraint FK_UID ;
SQL> alter table w.table_name drop constraint pk_id;
table altered
SQL>alter table x.table_name drop constraint fk_uid;
table altered
SQL> drop user ORACLE cascade;
User dropped.
--使用者刪除成功
查詢出結果並刪除即可drop user oralce cascade了,因為這個報錯比較典型,網上還看到過很多種延伸出來的問題原因,記錄之。
推薦閱讀:
ORA-01172、ORA-01151錯誤處理
ORA-00600 [2662]錯誤解決
ORA-01078 和 LRM-00109 報錯解決方案
ORA-00471 處理方法筆記
ORA-00314,redolog 損壞,或丟失處理方法
ORA-00257 歸檔日誌過大導致無法儲存的解決辦法