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

来源:互联网 发布:自行车软件 编辑:程序博客网 时间:2024/05/17 01:36

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 1000SQL> 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                 PALERT_IDALERT_NOTE                     R ALERT_NOTE_ALERT_STORE_FKALERT_IDALERT_STORE                    ALERT_STORE_PK                 PALERT_IDALERT_EMAIL_JOB                R ALRT_EMAIL_JOB_ALRT_STORE_FKALERT_IDALERT_STORE                    ALERT_STORE_PK                 PALERT_IDALERT_TROUBLETICKET_JOB        R ALRT_TTKT_JOB_ALRT_STORE_FKALERT_IDSQL>  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 keywordSQL>   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 suchconstraintSQL>   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
原创粉丝点击