ORA 2266 -- Drop parent partition with no child records exists

Hi Team ,
Here I have a parent partitioned table and child refrenced non-partition table .
To drop parent partition I am doing
1)delete from child
2)delete from parent partition
3)alter table drop parent partition
---and its working fine .
I am trying to do below which is not working , Could you please guide me why it is not
1)delete from child
2)alter table drop parent partition -- throwing below error
Summarizing ,
Why I am not able to drop/trunc a parent partition(no corresponding rows exists in child tables) where as able to do after deleting the rows from parent partition .
From Doc :
Error: ORA 2266
Text: table has some unique/primary keys that are referenced by some foreign k
eys
Cause: Attempt to drop the table while the table still has some unique/
primary keys that are referenced by some foreign keys.
Action: Remove all such references to the keys before dropping the table
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE     11.2.0.2.0     Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

Oracle decides what the rules are & you must conform to them
bcm@bcm-laptop:~$ oerr ora 2266
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";

Similar Messages

  • Drop parent table with disabled child constraints?

    I have a table I would like to drop and recreate. I do not want to have to recreate all the foreign key constraints again. Can I disable the foreign key constraints, drop the table and then recreate the table and enable the foreign key constraints?
    Thanks,
    John E.

    No.
    The Triggers,Indexes,Constraints etc, assocated with a table are bound to the table they are defined for.
    They owe their existance to the existance of the table.
    If the table goes, so do the constraints.
    If you have Oracle9i, can use DBMS_METADATA to generate the DDL script of the table before dropping it.

  • APP-PAY-07201 Cannot perform a delete when child record exists in future

    I am trying to put end date to a payment method of any employee in HR/Payroll 11.5.10.2
    but receiving the following error message:
    APP-PAY-07201 Cannot perform a delete when child record exists in future
    Can u advise what steps I should follow to resolve this issue.
    Regards /Ali

    This note is related to termination of employee while our employee is on payroll and just want to change is payment method. But in the presence of existing payment method we cannot attched another becuase we are receiving an error:
    APP-PAY-07041: Priority must be unique within an orgainzational payment method

  • Join  a Parent Table with 2 Child table based on a value

    Dear Guru's
    We have a Parent Table and 2 Child table . The Parent Table has a column like seqtype with only 2 possible values C and S . If the Value is C , then the details are available in Child 1 table and if the Value is S then the Details are in Child 2 table
    How can we query the Data from this type of arrangement ? I am little bit confused and hit a road block
    Will the following query will work ?
    Select
    from Parent P , Child C1, Child C2
    where P.seqtype = C1.Seqtype
    and P.seqtype = C2.Seqtype
    With Warm Regards
    ssr

    You didn't mention the column names in two child tables. Whether the columns are same in 2 tables of these are different.
    If the columns are same better to go and change your design to have only one child table. However if stiil business stops you having one table you can use UNION ALL (Assuming you want to fetch same column information from two child tables) like below:
    SELECT p.col1
          ,c1.col2
          ,c1.col3
          ,c1.col4
      FROM parent     p
          ,child      c1
    WHERE p.seqtype = c1.seqtype
    UNION ALL
    SELECT p.col1
          ,c2.col2
          ,c2.col3
          ,c2.col4
      FROM parent     p
          ,child      c2
    WHERE p.seqtype = c2.seqtype Regards
    Arun

  • Drop a partition with a corrupt datafile in the associated tablespace

    Hello,
    I desperately need to drop a partition. However, I am unable to do so as the datafile in the associated tablespace for the partition is corrupt. When I attempt to drop the partition, I receive the following error:
    ORA-00376: file 16 cannot be read at this time.
    ORA-01110: data file 16: '/data3/oradata/cdn/data/tran_part_20051115.dbf'
    Is there any way to get rid of the corrupted datafile so that I can successfully drop the partition? Maintaining the data is not a concern at this point. The priority is to solve this issue, so data loss is not a concern for me.
    Any assistance would be greatly appreciated!
    Thanks,
    Scott

    Does the file '/data3/oradata/cdn/data/tran_part_20051115.dbf' exist on the disk?
    What does; select distinct status from V$recover_file indicate?
    Thanks
    Chandra Pabba

  • CMR - how to deal with no child records

    Hi,
    I have developed a number of CMP EJBs, created relationships, mapped and deployed OK using WSAD v5 + DB2 backend. When I call findByPrimaryKey on the parent in the one to many, everything works unless there are no child records. The server generates a ObjectNotFoundException and the data in the parent record is not accessible.
    TIA for any advice.
    Jim

    Don't you love it when Sun does an implementation that sucks, does not document it properly, and does not even bother to answer your questions in the forum... You'd think that after these many years they would have gotten it right. I am also having a similar problem and I have seen it on many postings, but no answers... :P

  • 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

  • Help with Update if record exists else insert record  "upsert"

    Hi Friends,
    i have this table:
    CREATE
      TABLE TB_GEN_COMPANY
        "ID_COMPANY"   NUMBER NOT NULL ENABLE,
        "COD_CODIGO"    VARCHAR2(10 BYTE) NOT NULL ENABLE,
        "DES_NAME"    VARCHAR2(64 BYTE) NOT NULL ENABLE,
        "DES_DIRECTION" VARCHAR2(128 BYTE) NOT NULL ENABLE,
        "COD_RUC"       CHAR(11 BYTE) NOT NULL ENABLE,
        "FLG_EST"    CHAR(1 BYTE) NOT NULL ENABLE,
        "COD_USR_CR"  VARCHAR2(16 BYTE) NOT NULL ENABLE,
        "FCH_FEC_CR" TIMESTAMP (6) NOT NULL ENABLE,
        "COD_USR_MOD" VARCHAR2(16 BYTE) NOT NULL ENABLE,
        "FCH_FEC_MOD" TIMESTAMP (6) NOT NULL ENABLE,
        CONSTRAINT "TB_GEN_COMPANIA_ESTADO_CHK" CHECK (FLG_ESTADO IN ('A', 'I'))
        CONSTRAINT "TB_GEN_COMPANIA_PK" PRIMARY KEY ("ID_COMPANIA")
      )I want to validate the code (cod_codigo). if the record exists, i will have to update with the news inputs parameters, otherwise it should create a new one i mean, an Insert.
    Thanks for t he help.
    Sorry for bad engl.

    i have this:
    DECLARE
        strCod_Compania  VARCHAR2(10):='123';
        strdes_Nombre  VARCHAR2(64):='compname';
        strdes_Direccion  VARCHAR2(128):='calle las 123 santa beatriz';
        strCod_CompaniaRuc  VARCHAR2(11):='12345678911';
    BEGIN
    MERGE INTO TB_GEN_COMPANIA e
    USING
    TB_GEN_COMPANIA d
    ON (e.cod_codigo=strCod_Compania)
    WHEN MATCHED THEN
      UPDATE
      SET e.DES_NOMBRE=strdes_Nombre,
          e.DES_DIRECCION=strdes_Direccion,
          e.COD_RUC=strCod_CompaniaRuc,
          e.FLG_ESTADO='A'
    WHEN NOT MATCHED THEN
    INSERT (COD_CODIGO,
            DES_NOMBRE,
            DES_DIRECCION,
            COD_RUC,
            FLG_ESTADO,
            COD_USR_CREA,
            FCH_FEC_CREA,
            COD_USR_MOD,
            FCH_FEC_MOD)
    VALUES
            (strCod_Compania,
            strdes_Nombre,
            strdes_Direccion,
            strCod_CompaniaRuc,
            'A',
            'rmolina',
            SYSDATE(),
            'rmolina2',
            SYSDATE());
    END;
    /this is my table:
    CREATE TABLE "TB_GEN_COMPANIA"
       (     "COD_CODIGO" VARCHAR2(10 BYTE),
         "DES_NOMBRE" VARCHAR2(64 BYTE),
         "DES_DIRECCION" VARCHAR2(128 BYTE),
         "COD_RUC" CHAR(11 BYTE),
         "FLG_ESTADO" CHAR(1 BYTE),
         "COD_USR_CREA" VARCHAR2(16 BYTE),
         "FCH_FEC_CREA" TIMESTAMP (6),
         "COD_USR_MOD" VARCHAR2(16 BYTE),
         "FCH_FEC_MOD" TIMESTAMP (6)
       )OK, when i execute the first query, 4 records are inserted in my table, and i don't know why,
    any idea to solve this please?
    Thanks

  • [Answers] Parent section with all childs of all members

    Hi all,
    I am trying to do a pivot table having in 'Sections' a parent hierarchy level, and the child in 'Columns' , so in every section created I get all the members of the child level with empty values.
    Normally we should have in a specific section only the childs of the corresponding parent level member, How can we do this plz.
    If it's not very well explained please tell so.
    Thanks

    I'm sorry, Elazhari, I am a bit confused.
    Are you saying there is an error or problem, or you just don't know how to do it?
    Do you have the parent-child hierearchy set up correctly in your rpd? If so, it should be no problem. Say you have Regions>District>Branches with this hierarchy set up.
    Then in your pivot table, you can have Regions in the "Pages" section, District in the "Sections" section, and the Branches will be in your rows.
    Under each parent level, the children would be as you would expect. I anticipate that there is more, so if this doesn't help you, please supply more information.

  • How to obtain parent record from child record in relationship using API

    Hi,
    I have a record in the main table that is the child in a parent/child relationship to another main table record.  Using the Java API, how would I obtain the parent record in the relationship where I am starting with the child record?  In the API there seems to just be calls for getChildren, but not a getParent type call.
    Appreciate any immediate help that can be provided.
    Thanks,
    Eddie

    Hi Eddie,
    Please follow the below steps to retrieve only parents of a child Record.
    1. Create RetrieveRelationshipsCommand.
    2. Set the parameter RelationshipId.
    3. Set the parameter Anchor Record and Anchor Record Id. In this case the child record for which parents records to be retrieved.
    4. Set the parameter setGetChildren as false . This retrieves only the parent records for the specified child reocrd.
    5. Execute the RetrieveRelationshipsCommand.
    6. Retrieve member records from above step.
    Hope it helps
    Regards,
    Neeharika

  • Deleting rows with child records

    Hi,
    I want to delete some records from master table based on where condition. But I want all the corresponding child record should also delete from the respective child tables..
    Can anyone tell me how to go about it with example( eg emp & dept table of scotts)
    Regards

    I have been to slow for posting...
    Please note that I hate doing this
    SCOTT@LSC01> select count(*) from emp;
      COUNT(*)
            14
    SCOTT@LSC01> delete dept where deptno=10;
    <font color=red>1 row deleted.</font>
    SCOTT@LSC01> select count(*) from emp;
      COUNT(*)
            11the risk is that someone is not aware of deleting rows, and instead of getting
    SCOTT@LSC01> delete dept where deptno=10;
    delete dept where deptno=10
    ERROR at line 1:
    ORA-02292: integrity constraint (SCOTT.FK_DEPTNO) violated - child record foundhe is deleting rows in other tables and will never be aware of that deletion ...

  • How to find child records is exists before to delete parent records.

    Dear Everyone,
    I would like to ask you, is there any simple way to find child records is exists before to delete parent records.
    I have a master table defined primary key and I have referenced that as foreign key in many tables.
    I have used Delete_Record to delete but it isn't display the message 'child record exist' but it cleared the record from the form. So I need to know how to find child records is exists or not before to do delete_record so that I can display message in-case it exists.
    I do know we can able to check in every table matching the column manually, but what if we use 100 of tables then it is not possible to check manually.
    I am sure there must be simple way to find as how the oracle identifies when we execute delete query.
    Please help me on this.
    Thanks in advance.

    Simple solution is to run the query I have given for all child tables or to try a single query for all child tables withj something like:
    select <parent_key>
    from <parent_table>
    where <parent_key> in
              (select <foreign_key_1> from <child_table_1> union
               select <foreign_key_2> from <child_table_2> union
               ... );More complicate solution could be to change the foreign key constraints to cascade DELETE on parent table to child tables:
    SQL>
    SQL> create table p(x int primary key);
    Table created.
    SQL> create table c1(x1 int);
    Table created.
    SQL> create table c2(x2 int);
    Table created.
    SQL>
    SQL> alter table c1 add constraint fk1 foreign key(x1) references p;
    Table altered.
    SQL> alter table c2 add constraint fk2 foreign key (x2) references p;
    Table altered.
    SQL>
    SQL>
    SQL> insert into p values(1);
    1 row created.
    SQL> insert into c1 values(1);
    1 row created.
    SQL> insert into c2 values(1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> alter table c1 drop constraint fk1;
    Table altered.
    SQL> alter table c2 drop constraint fk2;
    Table altered.
    SQL>
    SQL> alter table c1 add constraint fk1 foreign key(x1) references p on delete cascade;
    Table altered.
    SQL> alter table c2 add constraint fk2 foreign key (x2) references p on delete cascade;
    Table altered.
    SQL>
    SQL> delete p where x=1;
    1 row deleted.
    SQL> commit;
    Commit complete.
    SQL> select * from p;
    no rows selected
    SQL> select * from c1;
    no rows selected
    SQL> select * from c2;
    no rows selected
    SQL>Edited by: P. Forstmann on 27 oct. 2011 14:01

  • Query to delete both parent and child record....

    hai.........
    I tried to delete a record from the table.... but i get a error saying 'child record' exist cannot delete record'.... can u plz tell me the query to delete both parent and child record....
    plz help me.....
    anoo...

    Hello,
    Is already answered in {thread:id=824593}. Please mark the question as answered.
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    http://www.bloggingaboutoracle.org/
    http://www.logica.com/

  • Integrity constraint child record found

    TopLink Version: Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070323)
    I may be going crazy here, but I keep getting an integrity constraint when I try to delete an object that has 1:M relationship (Resource 1:M Attribute):
    Internal Exception: java.sql.SQLException: ORA-02292: integrity constraint (WEBCENTER.WP_RELATIONSHIP_RES_FK) violated - child record found
    The child object attribute is set to "Private Owned", and there is an FK from the child table to the parent table in the database (this is where the integrity constraint violation is coming from).
    I query for the Resource, register it in the unit of work, call UOW.deleteObject(resource), and then call UOW.commitAndResume(). TopLink is making a sql call to delete the Resource, but it does not first delete the privately owned Attributes which results in the FK violation.
    It should delete the child records first, right?
    In addtion to having the attribute set to "Private Owned", I also have set:
    Batch Reading
    Use Indirection
    Transparent
    Not sure if that makes a difference.

    Use a trigger. Example:
    CREATE OR REPLACE TRIGGER update_parent_chilren
    BEFORE UPDATE OF pkey_column ON parent_table
    FOR EACH ROW
    BEGIN
    UPDATE child_table
    SET fkey_column = :NEW.pkey_column
    WHERE fkey_column = :OLD.pkey_column;
    END update_parent_children;
    null

  • How to identify violeted child record

    Hi,
    I want to delete a record in project_objects table it is giving me this error.
    How to idetify the table which is getting related to this table.
    ORA-02292: integrity constraint (NAIODEV.TEMP_TEY_POB_ID_FK) violated - child record found
    Please suggest me is there any command. to know.
    Thanks
    Sudhir.

    Select Table_Name,constraint_Name, Constraint_Type,r_Constraint_Name
      From User_Constraints A
    Where R_Constraint_Name =(Select Constraint_Name
                                 From User_Constraints B
                                      Where Table_Name='EMP'
                                        And Constraint_Type='P'
      And Constraint_Type='R'
      Select Table_Name,constraint_Name, Constraint_Type,r_Constraint_Name
      From User_Constraints A
    Where Constraint_Name In (Select r_Constraint_Name
                             From User_Constraints B
                                  Where Table_Name='EMP'
                                    And Constraint_Type='R'
                                    Group By r_Constraint_Name
      And Constraint_Type='P'
    table :-  USER_CONS_COLUMNS

Maybe you are looking for