ORA-02266

Hello All,
I am trying to truncate a table.
I am wondering following message.
ORA-02266: unique/primary keys in table referenced by enabled foreign keysAny help?
Thanks,
S!G

Sea!Gull,
TRUNCATE table operation does not enforce for foreign key constraint at data or row level. Even if there are no rows in any table (parent and child) truncate on parent will give this error a long as the FK constraint exists and is enabled.
You have to disable the FK constraints in the "child/detail" table(s), in order to truncate "parent/master" table.
Think about it, if TRUNCATE table enforced FK constraints at row/data level, it will not be any faster than DELETE statement. TRUNCATE bypasses lots of internal processes like FK checks, row level logging etc.
SQL> drop table d;
Table dropped.
SQL> drop table m;
Table dropped.
SQL> create table m (c int primary key);
Table created.
SQL> create table d (c1 int, constraint d_fk foreign key (c1) references m(c));
Table created.
SQL> select * from m;
no rows selected
SQL> select * from d;
no rows selected
SQL> truncate table m;
truncate table m
ERROR at line 1:
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
SQL> alter table d disable  constraint d_fk ;
Table altered.
SQL> truncate table m;
Table truncated.
SQL> alter table d enable  constraint d_fk ;
Table altered.
SQL> truncate table m;
truncate table m
ERROR at line 1:
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
SQL> Regards,
Sudhakar B.
Edited by: user517570 on Jan 6, 2010 9:57 AM (Added the code tag)

Similar Messages

  • How to truncate the Dimensions: ORA-02266

    I simply want to truncate the dimensions of star schema.
    First I truncate the fact table with Sql, that works.
    Then truncating a dimension fails with this error:
    Truncate table fcDwh.DIM_DEPS
    Error report:
    SQL Error: ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    02266. 00000 - "unique/primary keys in table referenced by enabled foreign keys"
    *Cause:    An attempt was made to truncate a table with unique or
    primary keys referenced by foreign keys enabled in another table.
    Other operations not allowed are dropping/truncating a partition of a
    partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    *Action:   Before performing the above operations the table, disable the
    foreign key constraints in other tables. You can see what
    constraints are referencing a table by issuing the following
    command:
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = "tabnam";
    If the fact table is already empty, I don't violate any foreign key constraint.
    Or am I wrong with this?
    The constraints below:
    OWNER CONSTRAINT_NAME CONSTRAINT_TYPE TABLE_NAME SEARCH_CONDITION R_OWNER R_CONSTRAINT_NAME DELETE_RULE STATUS DEFERRABLE DEFERRED VALIDATED GENERATED BAD RELY LAST_CHANGE INDEX_OWNER INDEX_NAME INVALID VIEW_RELATED
    FCDWH SYS_C0019008 C DIM_DEPS "DIMENSION_KEY" IS NOT NULL ENABLED NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 07-SEP-07
    FCDWH DIM_DEPS_DIMENSION_KEY_PK P DIM_DEPS ENABLED NOT DEFERRABLE IMMEDIATE VALIDATED USER NAME 07-SEP-07 FCDWH DIM_DEPS_DIMENSION_KEY_PK

    Try using NumberFormat class:
    NumberFormat currency = NumberFormat.getNumberInstance();
    currency.setMinimumFractionDigits(2);
    currency.setMaximumFractionDigits(2);
    String s = currency.format(anyFloatValue);
    ..

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

    Hi,
    I am trying to delete data from a table by dropping a partition. I have identified all the child tables by running the following command.
    select 'select count(*) from '||table_name||' where employee_id = 100;'
    from dba_constraints
    where constraint_type='R'
    and r_constraint_name in
    (select constraint_name from dba_constraints
    where constraint_type in ('P','U') and table_name='EMPLOYEE);
    'SELECTCOUNT(*)FROM'||TABLE_NAME||'WHEREEMPLOYEE_ID_ID=100;'
    select count(*) from PT_ORDERS where employee_id = 100;
    select count(*) from PT_DEP where employee_id = 100;
    select count(*) from PT_SKILLSET where employee_id = 100;
    I dropped the partition for employee_id 100 in all of the child tables. The select count(*) returns 0 rows for each of the above.
    When I try to run the below command on the EMPLOYEE table, I get 'ORA-02266: unique/primary keys in table referenced by enabled foreign keys'.
    alter table EMPLOYEE drop partition EMP_ID_100;
    I cant see why I am unable to drop this partition now as there is now child data in any of the referenced tables. Any suggestions or help on this would be greatly appreciated.
    Thanks.
    Rgs,
    Rob

    You should disable foreign key constraints first and drop partition. Deletion of rows or dropping partitions in childs don't work in this case
    as you have the global dependency:
    <PRE>
    SQL> create table scott.t (x int primary key, y int)
    2 partition by list (y) (
    3 partition p_1 values(1), partition p_2 values(2))
    4 /
    Table created.
    SQL> create table scott.t_c (x int references scott.t(x), y int)
    2 partition by list (y) (
    3 partition p_1 values(1), partition p_2 values(2))
    4 /
    Table created.
    SQL> insert into scott.t values(1,1)
    2 /
    1 row created.
    SQL> insert into scott.t values(2,2)
    2 /
    1 row created.
    SQL> insert into scott.t_c values(1,1)
    2 /
    1 row created.
    SQL> insert into scott.t_c values(2,2)
    2 /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> alter table scott.t_c drop partition p_2;
    Table altered.
    SQL> alter table scott.t drop partition p_2;
    alter table scott.t drop partition p_2
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> select constraint_name from dba_constraints
    2 where owner = 'SCOTT' and constraint_type = 'P'
    3 and table_name = 'T';
    CONSTRAINT_NAME
    SYS_C0011058
    SQL> select constraint_name from dba_constraints
    2 where owner = 'SCOTT' and constraint_type = 'R'
    3 and r_constraint_name = 'SYS_C0011058';
    CONSTRAINT_NAME
    SYS_C0011059
    SQL> alter table scott.t_c disable constraint SYS_C0011059;
    Table altered.
    SQL> alter table scott.t drop partition p_2;
    Table altered.
    SQL> alter table scott.t_c enable novalidate constraint SYS_C0011059;
    Table altered.
    </PRE>
    I guess you should consider such option as Referencial partitioning (with some restrictions).
    Best wishes,
    Dmitry.

  • Stuck with ORA-02266...even through I've already disabled the FK constraints...?

    I'm working to help some people on a structure I really don't know much about...they're trying to truncate the table.
    When trying to truncate table1:
    I got the ORA-02266: unique/primary keys in table referenced by enabled foreign keys error,
    I went through and have disabled every FK on the table....so, I'm a bit puzzled why I keep getting the same error.
    I was thinking of disabling the PK...to see if for some reason that was holding things back (so far out of a bunch of tables, this is the ONLY table not responding to having all FK's disabled).
    However, when I try to disable the PK I get:
    ORA-02297: cannot disable constraint (owner.table1_pk) - dependencies exist
    I've been looking around, and was going to maybe try the disable constraint with the cascade option, but, I'm not familiar with the cascade in this context...what will this do?
    Will it cause any problems with this or other tables when I try to re-enable the PK constraint on table1?
    Thank you in advance,
    cayenne

    Thank you, this looks like I'm on the path to untangling this mess.
    One question, please...would disabling the PK constraint with the CASCASE clause take care of this? What would this do exactly...disable the other tables' FK constraints..?
    If so, would it re-enable them when I re-enable this PK constraint?
    Thank you,
    C

  • ORA-02266: unique/primary keys - error while using Exchange Partition

    Hi All,
    While using EXCHANGE PARTITION statement as given below,
    ALTER TABLE SOURCE_TABLE EXCHANGE PARTITION PRT_EXCG_PRTN WITH TABLE TARGET_TABLE
    we are getting this error,
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    However, there are no tables have foreign keys referring this TARGET_TABLE, we checked this by referring
    USER_CONSTRAINTS table, it has only primary key and NOT NULL constraints.
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME like 'TARGET_TABLE';
    We are using the following version,
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    PL/SQL Release 9.2.0.6.0 - Production
    CORE     9.2.0.6.0     Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
    NLSRTL Version 9.2.0.6.0 - Production
    Is it due to any error in our end or it could be a bug in Oracle and should we go for any patch updation ?
    Please guide us to resolve this error as soon as possible, thank you.
    Regards,
    Deva

    *** Duplicate Post ***
    Please Ignore.

  • Truncate table ORA-02266

    Hi,
    when I truncate some tables I have ORA-02266 error. Any Idea or solution ?
    Many thanks.

    Hi,
    >>1-Is there any way to disable all primary key constarints and all dependencies on all >>tables of a schema and after operation turn back ?
    See this example below:
    SQL> alter table aet_em disable constraints aetem_pk;
    alter table aet_em disable constraints aetem_pk
    ERROR at line 1:
    ORA-02297: cannot disable constraint (SGMS.AETEM_PK) - dependencies exist
    SQL> select table_name,constraint_name,status from user_constraints where r_constraint_name='AETEM_PK';
    TABLE_NAME                     CONSTRAINT_NAME                STATUS
    AET_IEM                        AETIEM_FK2                     ENABLED
    SQL> alter table aet_em disable constraints aetem_pk cascade;
    Table altered.
    SQL> select table_name,constraint_name,status from user_constraints where r_constraint_name='AETEM_PK';
    TABLE_NAME                     CONSTRAINT_NAME                STATUS
    AET_IEM                        AETIEM_FK2                     DISABLED
    SQL>After performed this operation, you need to enable the foreign keys manually.
    Cheers

  • Partitioned nested table error while dropping one partition

    All,
    I created a partitioned table which is also a nested table as you can see below. I got FK constraint error while attempting to drop a partition, however, I could not find the FK in order to disable it since it's underlying table emp_list_p which is not visiable to applications. How could I drop the partition in this case?
    Thanks,
    Jianhui
    SQL>desc emp_t
    Name Null? Type
    ENO NUMBER
    ENAME VARCHAR2(30)
    SAL NUMBER
    SQL>desc emp_list_t
    emp_list_t TABLE OF EMP_T
    Name Null? Type
    ENO NUMBER
    ENAME VARCHAR2(30)
    SAL NUMBER
    SQL>l
    1 create table dept_p
    2 (dno number,
    3 dname varchar2(30),
    4 emplist emp_list_t )
    5 NESTED TABLE emplist store as emp_list_p
    6 partition by range (dno)
    7 (
    8 partition p1 values less than (2),
    9 partition p2 values less than (3)
    10* )
    SQL>/
    Table created.
    SQL>insert into dept_p (select * from dept);
    2 rows created.
    SQL>select * from dept_p;
    DNO DNAME
    EMPLIST(ENO, ENAME, SAL)
    1 HR
    EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000))
    2 SALES
    EMP_LIST_T(EMP_T(3, 'frank', 800))
    2 rows selected.
    SQL>alter table dept_p drop partition p1;
    alter table dept_p drop partition p1
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL>l
    1 select constraint_name, constraint_type, table_name
    2 from user_constraints
    3 where r_constraint_name=(select constraint_name
    4* from user_constraints where table_name='DEPT_P' and constraint_type in ('P','U'))
    SQL>/
    no rows selected

    SQL> create type emp_t as object(
      2  ENO NUMBER,
      3  ENAME VARCHAR2(30),
      4  SAL NUMBER)
      5  /
    Type created.
    SQL> create type emp_list_t as table of emp_t;
      2  /
    Type created.
    SQL> desc emp_list_t
    emp_list_t TABLE OF EMP_T
    Name                                      Null?    Type
    ENO                                                NUMBER
    ENAME                                              VARCHAR2(30)
    SAL                                                NUMBER
    SQL> create table dept_p
      2  (dno number,
      3  dname varchar2(30),
      4  emplist emp_list_t )
      5  NESTED TABLE emplist store as emp_list_p
      6  partition by range (dno)
      7   (
      8   partition p1 values less than (2),
      9   partition p2 values less than (3)
    10   )
    11  /
    Table created.
    SQL> insert into dept_p values(1, 'HR',
      2  EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000)));
    1 row created.
    SQL>
    SQL> insert into dept_p values(2, 'SALES',EMP_LIST_T(EMP_T(3, 'frank', 800)));
    1 row created.
    SQL> select * from dept_p;
           DNO DNAME
    EMPLIST(ENO, ENAME, SAL)
             1 HR
    EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000))
             2 SALES
    EMP_LIST_T(EMP_T(3, 'frank', 800))
    SQL> alter table dept_p drop partition p1;
    alter table dept_p drop partition p1
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> select constraint_name,table_name,constraint_type from user_constraints
      2  where table_name = 'DEPT_P';
    CONSTRAINT_NAME                TABLE_NAME                     C
    SYS_C008224                    DEPT_P                         U
    SQL> select index_name from user_constraints
      2  where table_name = 'DEPT_P';
    INDEX_NAME
    SYS_C008224
    SQL> select index_name,column_name from user_ind_columns
      2  where index_name = 'SYS_C008224';
    INDEX_NAME                     COLUMN_NAME
    SYS_C008224                    EMPLIST
    SQL>
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
    With the Partitioning, OLAP and Data Mining options
    If you look closely, there is a unique index on dept_p.  Oracle does not advertise it.
    One of the options is that you may have to delete the rows in the partition first,
    then drop the partition.

  • How to Drop all data in a database?

    Hi There,
    I'm use to dropping all the objects in a database, however, how do I drop ONLY the DATA in the database? Is all data in the database stored in tables? Do I have to TRUNCATE all the tables in the database only? Thanks in advanced.
    J

    You can try to:
    1. disable foreign key constraints instead of dropping them.
    2. truncate all tables in any order
    3. enable foreign key constraints.
    Short example:
    SQL> truncate table parent;
    truncate table parent
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> select constraint_name, table_name from user_constraints where r_constraint_name is not null;
    CONSTRAINT_NAME                TABLE_NAME
    SYS_C0011060                   CHILD
    JHIST_JOB_FK                   JOB_HISTORY
    JHIST_EMP_FK                   JOB_HISTORY
    JHIST_DEPT_FK                  JOB_HISTORY
    EMP_DEPT_FK                    EMPLOYEES
    EMP_JOB_FK                     EMPLOYEES
    EMP_MANAGER_FK                 EMPLOYEES
    DEPT_LOC_FK                    DEPARTMENTS
    DEPT_MGR_FK                    DEPARTMENTS
    LOC_C_ID_FK                    LOCATIONS
    COUNTR_REG_FK                  COUNTRIES
    11 rows selected.
    SQL> alter table child disable constraint sys_c0011060;
    Table altered.
    SQL> truncate table parent;
    Table truncated.
    SQL> truncate table child;
    Table truncated.
    SQL> alter table child enable constraint sys_c0011060;
    Table altered.
    SQL>

  • Oracle Materialized View replication

    I am perplexed by the fact that I have a slave sight full of MV's and a refresh group created to refresh with the Master site.
    When I refresh, however, the master site updates all of the tables (MV's) except one within my refresh group and all the changes I make on the MV site replicates to the Master site including this ONE MV.
    Where the problem lies is that the one MV does not accept any changes from the Master??
    Help!!

    Hello,
    I'm sorry to answer you so late.
    I could find an interesting Notes on My Oracle Support which gives a solution to this problem.
    Please, have a look on the following Notes:
    Complete refresh of a materialized view fails with ORA-02266 [ID 270456.1]In fact, you may have to add another MV to the Refresh Group so as to avoid the Truncate operation during the Refresh.
    If possible, you may also try a Fast Refresh (there's no Truncate in this case), but you'll need MV Log.
    Hope this help.
    Best regards,
    Jean-Valentin
    Edited by: Lubiez Jean-Valentin on May 19, 2010 11:44 PM

  • Drop partition without disabling foreign key

    Hi All,
    I have parent and child table.
    Parent table
    create table parent_1
    (id number,
    create_date date,
    constraint parent_1_pk001 PRIMARY KEY (id))
    PARTITION BY RANGE (create_date)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
    (PARTITION parent_1_part VALUES LESS THAN ('01-JAN-2010'));
    Child Table
    create table child_1
    (id number,
    create_date date,
    constraint child_1_fk001 FOREIGN KEY (id)
    REFERENCES parent_1 (id))
    PARTITION BY RANGE (create_date)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
    (PARTITION create_date_part VALUES LESS THAN ('01-JAN-2010'));
    I am having problems dropping partition.
    Parent_1
    1     26-JUL-12
    2     26-JUL-12
    Child_1
    1     26-JUL-12
    alter table CHILD_1 drop partition SYS_P274;
    table CHILD_1 altered.
    ON DROPPING PARENT PARTITION
    alter table parent_1 drop partition SYS_P273;
    Error report:
    SQL Error: ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    02266. 00000 - "unique/primary keys in table referenced by enabled foreign keys"
    *Cause:    An attempt was made to truncate a table with unique or
    primary keys referenced by foreign keys enabled in another table.
    Other operations not allowed are dropping/truncating a partition of a
    partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    *Action:   Before performing the above operations the table, disable the
    foreign key constraints in other tables. You can see what
    constraints are referencing a table by issuing the following
    command:
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = "tabnam";
    PLEASE CAN I KNOW IF THERE IS ANY WAY TO DROP PARENT PARTITION WITHOUT DISABLE/ENABLE FOREIGN CONSTRAINTS
    Thanks

    SQL Error: ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    02266. 00000 - "unique/primary keys in table referenced by enabled foreign keys"
    *Cause: An attempt was made to truncate a table with unique or
    primary keys referenced by foreign keys enabled in another table.
    Other operations not allowed are dropping/truncating a partition of a
    partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    *Action: Before performing the above operations the table, disable the
    foreign key constraints in other tables. You can't do that until you disable the foreign key constraint
    http://jonathanlewis.wordpress.com/2006/12/10/drop-parent-partition/
    Hope this helps
    Mohamed Houri
    www.hourim.wordpress.com

  • What are the differences between delete and truncate statements.

    i need few differences between executing both the above statements.like what is the effect they are going to make on the data in the table and regarding the table
    spaces

    One of the main diffrence TRUNCATE is DDL while DELETE is DML thats why
    you neednt to commit/rollbacked after TRUNCATING table.
    If you have master/child table then TRUNCATING master table will not concerned
    with child table data ,it will concerned with FK enabled KEY truncate is DDL.
    While DML will concerned with detail table data when deleting master table data.
    SQL> DESC dept
    Name                                      Null?    Type
    DEPTNO                                    NOT NULL NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    SQL> DESC emp
    Name                                      Null?    Type
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                    NOT NULL NUMBER(2)
    SQL> TRUNCATE TABLE emp
      2  /
    Table truncated.
    SQL> TRUNCATE TABLE dept
      2  /
    TRUNCATE TABLE dept
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> Unless you dont disable/drop FK key from child table you cant TUNCATE master
    table data.
    Khurram

  • Truncate giving problems.

    I had kept a process (PL/SQL block) running which was supposed to insert 4000000 rows in a table.
    But there was no COMMIT issued inside this block.
    By mistake I closed by SQL PLUS session.
    Next day when I issued the TRUNCATE command it gives me the error “ORA-02266: unique/primary keys in table referenced by enabled foreign keys”
    But there are no rows in this table
    See the details below
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
    With the Partitioning option
    JServer Release 8.1.7.4.0 - 64bit Production
    SQL> select count(*) from calc_policy_details;
    COUNT(*)
    0
    SQL> truncate table calc_policy_details;
    truncate table calc_policy_details
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> delete from calc_policy_details;
    0 rows deleted.
    SQL> truncate table calc_policy_details;
    truncate table calc_policy_details
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> select count(*) from calc_policy_details;
    COUNT(*)
    0

    This is a standard error message. When Oracle does a truncate, it simply marks all blocks used by the table as being unused. The blocks above MINEXTENT are released to free space and the rest are retained in the table.
    Because Oracle does not look at the data at all, this is a safeguard to avoid breaking referential integrity.
    SQL> CREATE TABLE t (id number PRIMARY KEY, descr VARCHAR2(10));
    Table created.
    SQL> CREATE TABLE tc (c_id NUMBER, id NUMBER REFERENCES t (id),
      2                   c_descr VARCHAR2(10));
    Table created.
    SQL> TRUNCATE TABLE t;
    TRUNCATE TABLE t
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    but
    SQL> DELETE FROM t;
    0 rows deleted.TTFN
    John

  • Truncate

    I am using truncate to delete large amount of records.I have one parent table and two child table. When i use truncate first for child table works ok,but when i use for parent table it showing me error
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    I am using truncte first for child table and after that for parent table !!! Any ideda

    I know there's a CASCADE option on the DROP command, but I have not found this in the DELETE.
    Would you, provide a reference?
    And the question posed was using TRUNCATE; so in order to use TRUNCATE on a 'master' table
    you would first have to remove the foreign keys.
    NO you do not need to drop foreign key constraint.
    I hope you want that whenever u delete master record for child record should also get deleted instead of giving error.
    Use delete command for master table with "cascade" option see sysntax of delete statement.
    Ripudaman

  • Truncating table throws error although no child record exists

    I have 2 tables
    table_master (This is master table)
    table_child (This is child table)
    truncate table table_child ;
    the above executes properly
    BUT
    truncate table table_master;
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    Although there is no child record even though the above error is occuring.Please sove my problem.

    Hi,
    >>lthough there is no child record even though the above error is occuring.Please sove my problem.
    In fact, doesn't matter if child table contain or not data.
    LEGATTI> create table a (id number primary key);
    Table created.
    LEGATTI> create table b (id number constraint fk_b_a references a);
    Table created.
    LEGATTI> truncate table a;
    truncate table a
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    LEGATTI> alter table b disable constraint fk_b_a;
    Table altered.
    LEGATTI> truncate table a;
    Table truncated.
    -- In addition, in order to drop the parent table, just disable the constraint's child table is not sufficient.
    LEGATTI> select constraint_name,status from user_constraints where table_name='B';
    CONSTRAINT_NAME                STATUS
    FK_B_A                         DISABLED
    LEGATTI> drop table a;
    drop table a
    ERROR at line 1:
    ORA-02449: unique/primary keys in table referenced by foreign keys
    LEGATTI> drop table a cascade constraints;
    Table dropped.
    LEGATTI> select * from user_constraints where table_name='B';
    no rows selectedCheers
    Legatti

  • I cannot "drop table"

    Hi,
    I've table BP:
    CREATE TABLE BP (
    BV_ID VARCHAR2 (32) DEFAULT NULL NOT NULL,
    BP_ID VARCHAR2 (32) DEFAULT NULL NOT NULL,
    CONSTRAINT BP_PK
    PRIMARY KEY ( BV_ID, BP_ID )
    BP has more 100 records:
    Now I'd like to drop table BP:
    drop table BP;
    ORA-02449: unique/primary keys in table referenced by foreign keys
    ALTER TABLE BP DISABLE CONSTRAINT BP_PK;
    ORA-02297: cannot disable constraint (BP_PK) - dependencies exist
    I tried disable all constraints with:
    select 'alter table '||table_name||' disable constraints '||constraint_name||';'
    from user_cons_columns
    where column_name='BV_ID'
    or column_name='BP_ID'
    but when I try drop table BP;
    ORA-02449: unique/primary keys in table referenced by foreign keys
    also truncate table BP:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    How can I drop table BP and disable all referenced by enabled foreign keys on table BP?
    Thanks!

    Or you could disable the foreign key constraint refering to primary key on the table and then drop the PK and then drop the table
    G

Maybe you are looking for

  • Report printing failure when not logged on as admin

    Using Business object XI,  I have a VB 2005 .NET app that works fine when logged on with admin privileges, but fails otherwise. I've investigated and traced this down a single line of code which is the  rep.PrintOut function. The debug error report i

  • Who knows why a JPanel is automatically painted twice? Please look at my co

    // "Raw Problem": Start this as Application or in Appletviewer // <applet code= ZaehlePaintAufrufe width=400 height=250> // </applet> import javax.swing.*; import java.awt.*; import java.awt.event.*; class Zeichnung extends JPanel private int calls =

  • Undefined error updating Adobe AIR on Windows Server 2008

    I am trying to upgrade from Adobe AIR version 2.7.1.1961 to version version 3.1.0.4880. The operating system is Windows Server 2008 Standard  - SP1 I am logged on as the administrator and shortly in the upgrade process, I receive a Window stating: So

  • How can I change a PDF to a Word document?

    Where in the product can I edit and change a PDF to Word Format?

  • Exchange rate type in BW

    Hi, I have an issue on Exchange rate type in BW. A new exchange rate type was created in R3, now I want to use the same in BW. For this, I have done the Global settings in BW on R3 source system and updated the exchange rate. After this, I could able