新聞中心
本篇文章重點為大家講解一下Oracle刪除表空間時遇到的一些問題以及解決方法,有需要的小伙伴可以參考一下。

成都做網站、網站設計、外貿營銷網站建設介紹好的網站是理念、設計和技術的結合。創(chuàng)新互聯擁有的網站設計理念、多方位的設計風格、經驗豐富的設計團隊。提供PC端+手機端網站建設,用營銷思維進行網站設計、采用先進技術開源代碼、注重用戶體驗與SEO基礎,將技術與創(chuàng)意整合到網站之中,以契合客戶的方式做到創(chuàng)意性的視覺化效果。
問題1:刪除表空間期間遭遇報錯 ORA-29857
刪除表空間語句:DROP TABLESPACE SAC INCLUDING CONTENTS AND DATAFILES; 根據MOS文檔: How To Resolve ORA-29857 During a Drop Tablespace although No Domain Index exists in This Tablespace (文檔 ID 1610456.1) 對于ORA-29857這個錯誤,文檔說的很清楚:
現象:
刪除表空間時,遇到報錯ORA-29857,例如: SQL> drop tablespace SAC including contents and datafiles
drop tablespace SAC including contents and datafiles
*
ERROR at line 1:
ORA-29857: domain indexes and/or secondary objects exist in the tablespace
然而,你并未在這個表空間中發(fā)現域索引:
SQL> SELECT OWNER,INDEX_NAME, TABLE_OWNER, TABLE_NAME
FROM DBA_INDEXES WHERE INDEX_TYPE='DOMAIN'
AND TABLESPACE_NAME ='SAC';
no rows selected
原因:
“
The table which is in the tablespace to be dropped has a domain index which needs to be dropped before dropping the tablespace. Domain indexes cannot be created in a specific tablespace and the TABLESPACE_NAME column in DBA_INDEXES is always null for domain indexes.
”
要刪除的表空間中的表有一個域索引,這個域索引在刪除表空間前需要被刪除掉。 域索引不能被創(chuàng)建在指定的表空間,對于域索引,DBA_INDEXES中的TABLESPACE_NAME列值總是空值。
解決方法:
You need to identify and drop the secondary objects: 你需要找出并刪除二級對象:
1.The domain index associated with a table in the tablespace to be dropped can be identified from the following query: 要刪除的與在這個表空間中的表相關的域索引可以通過下面的查詢找出來:
SQL> SELECT INDEX_NAME,I.TABLE_NAME FROM DBA_INDEXES I, DBA_TABLES T
WHERE T.TABLE_NAME=I.TABLE_NAME
AND T.OWNER=I.OWNER
AND I.INDEX_TYPE='DOMAIN'
and t.TABLESPACE_NAME='&TABLESPACE_NAME';
2.Secondary objects associated with domain indexes, can be identified from the following query: 與域索引相關的二級對象,可以通過下面的查詢找出來:
SQL> SELECT SECONDARY_OBJECT_OWNER,SECONDARY_OBJECT_NAME,SECONDARY_OBJDATA_TYPE FROM DBA_SECONDARY_OBJECTS WHERE INDEX_NAME='INDEX_NAME_From_Previous_Query';
Once you identify the secondary objects, you can drop those and then drop the tablespace. 一旦你找出這些二級對象,你就可以刪除它們然后再刪除表空間。
Please see the following example: 請看下面的例子:
SQL> CREATE TABLESPACE SAC DATAFILE 'C:\SAC.DBF' SIZE 50M;
Tablespace created.
SQL> CREATE TABLE SAC TABLESPACE SAC AS SELECT * FROM ALL_OBJECTS;
Table created.
SQL> begin
ctx_ddl.create_preference('SUBSTRING_PREF','BASIC_WORDLIST');
ctx_ddl.set_attribute('SUBSTRING_PREF', 'SUBSTRING_INDEX','TRUE');
end;
/
PL/SQL procedure successfully completed.
-- Trying to create the domain index in specific tablespace fails with ORA-29850:
SQL> CREATE INDEX SAC_INDX ON SAC(OBJECT_TYPE) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS ('WORDLIST SUBSTRING_PREF MEMORY 50M') TABLESPACE SAC;
CREATE INDEX SAC_INDX ON SAC(OBJECT_TYPE) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS ('WORDLIST SUBSTRING_PREF MEMORY 50M') TABLESPACE SAC
*
ERROR at line 1:
ORA-29850: invalid option for creation of domain indexes
SQL> CREATE INDEX SAC_INDX ON SAC(OBJECT_TYPE) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS ('WORDLIST SUBSTRING_PREF MEMORY 50M');
Index created.
SQL> drop tablespace sac including contents and datafiles;
drop tablespace sac including contents and datafiles
*
ERROR at line 1:
ORA-29857: domain indexes and/or secondary objects exist in the tablespace
-- Trying to find the domain index in this tablespace:
SQL> SELECT OWNER,INDEX_NAME, TABLE_OWNER, TABLE_NAME
FROM DBA_INDEXES WHERE INDEX_TYPE='DOMAIN'
AND TABLESPACE_NAME ='SAC';
no rows selected
--Trying to find segments created in this newly created tablespace:
SQL> SELECT SEGMENT_NAME,SEGMENT_TYPE FROM DBA_SEGMENTS WHERE TABLESPACE_NAME='SAC';
SEGMENT_NAME SEGMENT_TYPE
-------------------- ------------------
SAC TABLE
-- Trying to find the segment for index SAC_INDX :
SQL> SELECT TABLESPACE_NAME FROM DBA_SEGMENTS WHERE SEGMENT_NAME='SAC_INDX';
no rows selected
-- Trying to find the tablespace for index SAC_INDX from DBA_INDEXES :
SQL> set null null
SQL> select INDEX_TYPE,TABLE_TYPE,DOMIDX_STATUS,DOMIDX_OPSTATUS,SEGMENT_CREATED,TABLESPACE_NAME from DBA_INDEXES where INDEX_NAME='SAC_INDX';
INDEX_TYPE TABLE_TYPE DOMIDX_STATU DOMIDX SEG TABLESPACE_NAME
--------------------------- ----------- ------------ ------ --- ------------------------------
DOMAIN TABLE VALID VALID YES null
--To find the indexes that are causing ORA-29857 , please use the following query :
SQL> col TABLE_NAME for a30
SQL> col INDEX_NAME for a30
SQL> SELECT INDEX_NAME,I.TABLE_NAME FROM DBA_INDEXES I, DBA_TABLES T
WHERE T.TABLE_NAME=I.TABLE_NAME
AND T.OWNER=I.OWNER
AND I.INDEX_TYPE='DOMAIN'
and t.TABLESPACE_NAME='SAC';
INDEX_NAME TABLE_NAME
------------------------------ ------------------------------
SAC_INDX SAC
SQL> DROP INDEX SAC_INDX;
Index dropped.
--confirm that no secondary objects associated with domain index still exist:
SQL> SELECT SECONDARY_OBJECT_OWNER,SECONDARY_OBJECT_NAME,SECONDARY_OBJDATA_TYPE FROM DBA_SECONDARY_OBJECTS WHERE INDEX_NAME='SAC_INDX';
no rows selected
SQL> DROP TABLESPACE SAC INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
問題2:刪除表空間期間遭遇 ORA-02429
對于ORA-02429這個錯誤,MOS文檔的描述也很清楚: Drop Tablespace Failed with ORA-02429: cannot drop index used for enforcement of unique/primary key (文檔 ID 1918060.1)
現象:
刪除表空間失敗,伴隨下面的錯誤:
SQL> DROP TABLESPACE REP_DATA INCLUDING CONTENTS AND DATAFILES;
DROP TABLESPACE REP_DATA INCLUDING CONTENTS AND DATAFILES
*
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
解決方法:
Find the constraint name for the unique/primary key, disable the constraint and drop the tablespace again. 找到那些惟一/主鍵約束名,禁用這些約束然后再次刪除表空間。
Steps:
=====
1) Execute below query to find the constraint name:
執(zhí)行下面的查詢來找到約束名:
SQL> select owner, constraint_name,table_name,index_owner,index_name
from dba_constraints
where (index_owner,index_name) in (select owner,index_name from dba_indexes
where tablespace_name=' ' );
2) Disable the constraint:
禁用約束:
SQL> ALTER TABLE
DISABLE CONSTRAINT
; 3) Drop the tablespace: 刪除表空間: SQL> DROP TABLESPACE
INCLUDING CONTENTS AND DATAFILES;
問題3:表空間刪除完畢,主機磁盤空間不釋放
如果等待很長時間都沒有釋放,那么可參考:http://www.linuxidc.com/Linux/2016-04/130312.htm
“
建議的操作方法如下: 1、下載一個lsof軟件裝上,google上可以搜到 2、找到正在用被刪文件的進程 lsof | grep deleted 3、kill掉相應的進程空間就釋放了
”
一般這種情況,并不建議重啟數據庫或主機。
網站名稱:Oracle刪除表空間時遇到的一些問題以及解決方法
鏈接分享:http://m.fisionsoft.com.cn/article/coddjji.html


咨詢
建站咨詢
