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

SQL> truncate table alert_store;
truncate table alert_store
               *
ERROR at line 1:
ORA-02266: unique/primary keys in table referenced by enabled foreign keys



SQL> SET PAGESIZE 1000
SQL> select c1.table_name      as org_table_name,           
  2            c1.constraint_name as org_constraint_name,
  3            c1.constraint_type as org_constriant_type,
  4            n1.column_name     as org_colun_name,     
  5            c2.table_name      as ref_table_name,     
  6            c2.constraint_type as ref_constraint_type,
  7            c2.constraint_name as ref_constraint_name,
  8            n2.column_name     as ref_column_name     
  9       from dba_constraints  c1,                      
 10            dba_constraints  c2,                      
 11            dba_cons_columns n1,                      
 12            dba_cons_columns n2                       
 13      where c1.owner = 'AVSYS'                   
 14        and c1.table_name = 'ALERT_STORE'              
 15        and n1.constraint_name = c1.constraint_name   
 16        and n1.owner = c1.owner                       
 17        and c2.constraint_type = 'R'                  
 18        and c2.r_constraint_name = c1.constraint_name 
 19        and n2.owner = c2.owner                       
 20        and n2.constraint_name = c2.constraint_name;  

ORG_TABLE_NAME                 ORG_CONSTRAINT_NAME            O
------------------------------ ------------------------------ -
ORG_COLUN_NAME
--------------------------------------------------------------------------------
REF_TABLE_NAME                 R REF_CONSTRAINT_NAME
------------------------------ - ------------------------------
REF_COLUMN_NAME
--------------------------------------------------------------------------------
ALERT_STORE                    ALERT_STORE_PK                 P
ALERT_ID
ALERT_NOTE                     R ALERT_NOTE_ALERT_STORE_FK
ALERT_ID

ALERT_STORE                    ALERT_STORE_PK                 P
ALERT_ID
ALERT_EMAIL_JOB                R ALRT_EMAIL_JOB_ALRT_STORE_FK
ALERT_ID

ALERT_STORE                    ALERT_STORE_PK                 P
ALERT_ID
ALERT_TROUBLETICKET_JOB        R ALRT_TTKT_JOB_ALRT_STORE_FK
ALERT_ID


SQL>  ALTER TABLE AVSYS.ALERT_STORE DISABLE PRIMARY KEY CASCADE;

Table altered.

SQL>  truncate  table alert_store; 

Table truncated.

SQL>   ALTER TABLE AVSYS.ALERT_STORE enable PRIMARY KEY ;

Table altered.

SQL>   ALTER TABLE AVSYS.ALERT_STORE enable PRIMARY CONSTRAINT ALERT_NOTE_ALERT_STORE_FK;
  ALTER TABLE AVSYS.ALERT_STORE enable PRIMARY CONSTRAINT ALERT_NOTE_ALERT_STORE_FK
                                               *
ERROR at line 1:
ORA-00905: missing keyword


SQL>   ALTER TABLE AVSYS.ALERT_STORE enable  CONSTRAINT ALERT_NOTE_ALERT_STORE_FK;
  ALTER TABLE AVSYS.ALERT_STORE enable  CONSTRAINT ALERT_NOTE_ALERT_STORE_FK
*
ERROR at line 1:
ORA-02430: cannot enable constraint (ALERT_NOTE_ALERT_STORE_FK) - no such
constraint


SQL>   ALTER TABLE AVSYS.ALERT_NOTE enable  CONSTRAINT ALERT_NOTE_ALERT_STORE_FK;

Table altered.

SQL>   ALTER TABLE AVSYS.ALERT_EMAIL_JOB enable  CONSTRAINT ALRT_EMAIL_JOB_ALRT_STORE_FK;

Table altered.

SQL>   ALTER TABLE AVSYS.ALERT_TROUBLETICKET_JOB enable  CONSTRAINT ALRT_TTKT_JOB_ALRT_STORE_FK;

Table altered.

SQL> 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

huangliang0703

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值