首页 > Linux操作系统 > Linux操作系统 > ORA-02266: unique/primary keys in table referenced by enabled foreign keys
SQL> alter table t_user disable primary key cascade;
Table altered.
SQL> truncate table t_user;
Table truncated.
SQL> alter table t_user enable primary key;
Table altered.
把主键暂停后,外键也就失效了,一下语句查看失效的约束
select constraint_name,table_name,status from user_constraints where status='DISABLED';
构造使约束生效的脚本
SQL> select 'alter table '||table_name||' enable constraint '||constraint_name||';' from user_constraints where status='DISABLED';
SQL> alter table t_province_purview enable constraint fk_t_provin_relations_t_user;
Table altered.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16566331/viewspace-670764/ ,如需转载,请注明出处,否则将追究法律责任。