truncate table时发生ORA-02266错误

来源:互联网 发布:软件编程基础知识 编辑:程序博客网 时间:2024/04/29 03:51
今天想truncate一张表,但报ORA-02266错误
想到可能是主键被子表引用,查了一下
解决如下:
SQL> truncate table area;
truncate table area
               *
ERROR 位于第 1 行:
ORA-02266: 表中的唯一/主键被启用的外部关键字引用
ORA-02266: unique/primary keys in table referenced by enabled foreign keys


SQL> alter table area disable primary key cascade;

表已更改。

SQL> truncate table area;

表已截掉。

SQL> alter table area enable primary key;

表已更改。
原创粉丝点击