ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 删除表空间ORA-02429模拟及解决

删除表空间ORA-02429模拟及解决

原创 Linux操作系统 作者:lcmlsj 时间:2019-04-21 07:09:05 0 删除 编辑
SQL> drop tablespace csmbus including contents cascade constraints;
drop tablespace csmbus including contents cascade constraints
*
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


问题模拟:

SQL> create tablespace test1 datafile 'F:oracleproduct10.1.0oradatachangtest1.dbf' size 10m;

Tablespace created.

SQL> create index t2_ind on t2(object_id);

Index created.

SQL> drop tablespace test including contents and datafiles;

Tablespace dropped.

表的索引与表所处表空间对表空间删除没有影响。

SQL>

SQL> create table t
2 tablespace test
3 as select * from all_objects;

Table created.

SQL> alter table t add primary key(object_id)
2 using index
3 tablespace test1;

Table altered.

SQL> drop tablespace test1 including contents and datafiles;
drop tablespace test1 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
表t在test表空间,表t的主键索引在test1表空间。删除test1表空间出错。


create table t
tablespace test
as select * from all_objects;

SQL> create table t2(id number primary key,name varchar2(30),object_id references t(object_id))
2 tablespace test1;

Table created.

SQL> drop tablespace test including contents and datafiles;
drop tablespace test including contents and datafiles
*
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by foreign keys


SQL> drop tablespace test1 including contents and datafiles;

Tablespace dropped.

SQL>
表t在test表空间,表t2在test1表空间,表t2的外键引用表t的主键。删除表空间test1出错,但可以删除表空间test,即主表所在表空间可以删除。

这都是约束对表空间删除的影响,因此遇到该类错误试,应先删除约束,在删除表空间。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9599/viewspace-472942/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2002-04-09

  • 博文量
    100
  • 访问量
    114099