ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORA-02266: unique/primary keys in table referenced by enabled foreign keys

ORA-02266: unique/primary keys in table referenced by enabled foreign keys

原创 Linux操作系统 作者:os-ora 时间:2010-08-11 16:01:49 0 删除 编辑

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/ ,如需转载,请注明出处,否则将追究法律责任。

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

注册时间:2010-01-12

  • 博文量
    148
  • 访问量
    410408