ENABLE NOVALIDATE CONSTRAINT SYNTAX

Hi,
I have a table it's called loadsurvey which having some duplicate records. I would like to implement unique constraint on my table using following command which should not allow any new duplicate record into table and do not wants to validate existing record.
ALTER TABLE LOADSURVEY ADD ENABLE NOVALIDATE
CONSTRAINT LOAD_UNIQUE_CONS UNIQUE (METERNO,DAT,TIM);
SQL COMMAND WINDOWS SHOWS "ORA-01735: INVALID ALTER TABLE OPTION"
Any help me to come out the problem.
Regards,
Saravanan.

The syntax is
alter table .... add constraint ... (<column>) enable novalidate;
Please try to avoid using all uppercase for the subject line.
You don't need to shout.
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • Trying to implement a ENABLE NOVALIDATE constraint.....

    Hi ,
    In order to see how the ENABLE NOVALIDATE constraint in the DEPT table of SCOTT schema , i followed the following steps:
    1)Disable state
    SQL> alter table dept modify constraint pk_dept disable;
    Table altered2)Perform the operation (insert a row in for which the deptno preexists )
    SQL> insert into dept(deptno,dname) values(10,'dname10');
    1 row inserted
    SQL> commit;
    Commit complete3)Enable novalidate state
    SQL> alter table dept modify constraint pk_dept novalidate;
    Table altered4)Enable state
    SQL> alter table dept modify constraint pk_dept enable;
    alter table dept modify constraint pk_dept enable
    ORA-02437:cannot validate (SCOTT.PK_DEPT) - primary key violatedHow can i solve the problem.....?????
    Many thanks,
    Simon

    Hi,
    I haven't found any use of the NOVALIDATE parameter in the constraint.....
    In Oracle doc ... it's pointed out:
    "When a constraint is in the enable novalidate state, all subsequent statements are checked for conformity to the constraint. However, any existing data in the table is not checked. A table with enable novalidated constraints can contain invalid data, but it is not possible to add new invalid data to it. Enabling constraints in the novalidated state is most useful in data warehouse configurations that are uploading valid OLTP data.
    Enabling a constraint does not require validation. Enabling a constraint novalidate is much faster than enabling and validating a constraint. Also, validating a constraint that is already enabled does not require any DML locks during validation (unlike validating a previously disabled constraint). Enforcement guarantees that no violations are introduced during the validation. Hence, enabling without validating enables you to reduce the downtime typically associated with enabling a constraint."
    I have followed the steps in my first post to run a test case in order to see that the sentence above in bold, is implemented....
    But an error is displayed.....
    What should i have to do......????
    Many thanks ,
    Simon

  • Speeding up enable of constraints

    I have various constraints that used to take seconds and now are taking up to half an hr to enable. The data in the tables is static, it has increased or decreased. Does anyone know how to speed up the enabling of constraints on a table? What goes on behind the scenes after issuing alter table <table_name> enable constraint <constraint_name>;
    Thankis

    Dear HouseofHunger,
    Please tell me if that online documentation is enough for you or not?
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_3001.htm#i2183600
    +"+
    +Restrictions on Modifying Constraints Modifying constraints is subject to the following restrictions:+
    +*You cannot change the state of a NOT DEFERRABLE constraint to INITIALLY DEFERRED.+
    +*If you specify this clause for an index-organized table, then you cannot specify any other clauses in the same statement.+
    +*You cannot change the NOT NULL constraint on a foreign key column of a reference-partitioned table, and you cannot change the state of a partitioning referential constraint of a reference-partitioned table.+
    +See Also:+
    +"*Changing the State of a Constraint: Examples*"+
    +"+
    +"+
    +Changing the State of a Constraint: Examples The following statement places in ENABLE VALIDATE state an integrity constraint named emp_manager_fk in the employees table:+
    +ALTER TABLE employees+
    +ENABLE VALIDATE CONSTRAINT emp_manager_fk+
    +EXCEPTIONS INTO exceptions;+
    +Each row of the employees table must satisfy the constraint for Oracle Database to enable the constraint. If any row violates the constraint, then the constraint remains disabled. The database lists any exceptions in the table exceptions. You can also identify the exceptions in the employees table with the following statement:+
    +SELECT e.*+
    +FROM employees e, exceptions ex+
    +WHERE e.rowid = ex.row_id+
    +AND ex.table_name = 'EMPLOYEES'+
    +AND ex.constraint = 'EMP_MANAGER_FK';+
    +The following statement tries to place in ENABLE NOVALIDATE state two constraints on the employees table:+
    +ALTER TABLE employees+
    +ENABLE NOVALIDATE PRIMARY KEY+
    +ENABLE NOVALIDATE CONSTRAINT emp_last_name_nn;+
    +This statement has two ENABLE clauses:+
    +*The first places a primary key constraint on the table in ENABLE NOVALIDATE state.+
    +*The second places the constraint named emp_last_name_nn in ENABLE NOVALIDATE state.+
    +In this case, Oracle Database enables the constraints only if both are satisfied by each row in the table. If any row violates either constraint, then the database returns an error and both constraints remain disabled.+
    +Consider the foreign key constraint on the location_id column of the departments table, which references the primary key of the locations table. The following statement disables the primary key of the locations table:+
    +ALTER TABLE locations+
    +MODIFY PRIMARY KEY DISABLE CASCADE;+
    +The unique key in the locations table is referenced by the foreign key in the departments table, so you must specify CASCADE to disable the primary key. This clause disables the foreign key as well.+
    +"+
    Hope That Helps.
    Ogan

  • Enable Novalidate a table constraint

    I created a table with a unique constraint on one column DISABLED. I then proceeded to insert duplicate data in this field. When I try to ENABLE NOVALIDATE this constraint, I get the error ORA-02299: cannot validate (SCOTT.SARAH_U) - duplicate keys found. With the NOVALIDATE option, shouldn't it ignore existing records?
    My statement was: alter table sarah enable novalidate unique (cd);
    It seems as if the "novalidate" keyword is not being read.
    Thanks for any help.

    The syntax is:
    SQL> ALTER TABLE scott.sarah_u MODIFY CONSTRAINT <constraint_name> ENABLE NOVALIDATE;
    Hope this helps!
    Rob
    I created a table with a unique constraint on one column DISABLED. I then proceeded to insert duplicate data in this field. When I try to ENABLE NOVALIDATE this constraint, I get the error ORA-02299: cannot validate (SCOTT.SARAH_U) - duplicate keys found. With the NOVALIDATE option, shouldn't it ignore existing records?
    My statement was: alter table sarah enable novalidate unique (cd);
    It seems as if the "novalidate" keyword is not being read.
    Thanks for any help.

  • Questions on ENABLE NOVALIDATE a constraint

    I run the command on Oracle 11.2.0.1 on Redhat 5.2SQL> alter table agency add constraint agency_agcy_ori unique (agcy_ori) ENABLE NOVALIDATE;
    alter table agency add constraint agency_agcy_ori unique (agcy_ori) ENABLE NOVALIDATE
    ERROR at line 1:
    ORA-02299: cannot validate (DEVPF.AGENCY_AGCY_ORI) - duplicate keys found I knew the table has duplicate and null in the column which I want to add unique constraint. Using NOVALIDATE, I expect it tolarates the exist duplicate and valid new added data for uniqueness. Because it is stated in Oracle DOc B28286 that (page 8-15) ENABLE NOVALIDATE ensures that all new DML operations on the constrained
    data comply with the constraint. This clause does not ensure that existing data in
    the table complies with the constraintHowever, my database does not agree with this. Did I misunderstood the doc?
    Other related questions
    1) I have two rows with the column agcy_ori is NULL. Would that be considered duplicate and fails VALIDATE when create a unique constraint.
    2) The same doc also states (page 8-16) DISABLE VALIDATE disables the constraint and drops the index on the constraint,
    but keeps the constraint valid. This feature is most useful in data warehousing
    situations, because it lets you load large amounts of data while also saving space
    by not having an index. This setting lets you load data from a nonpartitioned table
    into a partitioned table using the exchange_partition_clause of the ALTER
    TABLE statement or using SQL*Loader. All other modifications to the table
    (inserts, updates, and deletes) by other SQL statements are disallowedThis raises more questions:
    a) DISABLE VALIDATE an unique constraint drop the unique index but still validate uniqueness. This is saying that te uniqueness is maintained without an unique index. If that is possible, why ENABLE an unique constraint need to create an unique index?
    b) The last setense 'All other modifications to the table by other SQL statements are disallowed'. This actually make the table read only except for partition/nonpartition and SQL*LOADER. This can be a useful feature but I do not see the logic here: Cannot update column2 of the table just because a constraint in column 10 is DISABLE VALIDATE.
    Hope people can help me here. Thanks.

    Re-read the documentation on the ENABLE clause
    at http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/clauses002.htm#g1053592
    ENABLE Clause
    Specify ENABLE if you want the constraint to be applied to the data in the table.
    +If you enable a unique or primary key constraint, and if no index exists on the key, then Oracle Database creates a unique index. Unless you specify KEEP INDEX when subsequently disabling the constraint, this index is dropped and the database rebuilds the index every time the constraint is reenabled.+
    You can also avoid rebuilding the index and eliminate redundant indexes by creating new primary key and unique constraints initially disabled. Then create (or use existing) nonunique indexes to enforce the constraint. Oracle does not drop a nonunique index when the constraint is disabled, so subsequent ENABLE operations are facilitated.
    Create a non-unique Index first.
    Hemant K Chitale

  • Doubt on ENABLE VALIDATE and ENABLE NOVALIDATE?

    Hi,
    I am doing the following things:
    SQL> create table xx_con(col1 number);
    Table created.
    SQL> insert into xx_con values(1);
    1 row created.
    SQL> insert into xx_con values(1);
    1 row created.
    SQL> insert into xx_con values(2);
    1 row created.
    SQL> alter table xx_con add constraint col1_uk unique(col1) enable validate;
    alter table xx_con add constraint col1_uk unique(col1) enable validate
    ERROR at line 1:
    ORA-02299: cannot validate (APPS.COL1_UK) - duplicate keys foundThis is exactly the same as the previous one.As per the documentation,when we specify "ENABLE VALIDATE" , all the existing and new data should comply with the constraint.But since the data violates the constraint,the constraint is not created .
    SQL> drop table xx_con;
    Table dropped.
    SQL> create table xx_con(col1 number);
    Table created.
    SQL> insert into xx_con values(1);
    1 row created.
    SQL> insert into xx_con values(1);
    1 row created.
    SQL> insert into xx_con values(2);
    1 row created.
    SQL> alter table xx_con add constraint col1_uk unique(col1) enable novalidate;
    alter table xx_con add constraint col1_uk unique(col1) enable novalidate
    ERROR at line 1:
    ORA-02299: cannot validate (APPS.COL1_UK) - duplicate keys foundAs per the documentation,when we specify "ENABLE NOVALIDATE", all the DML operations performed after this should comply with the constraint.But there can be existing data which voilates the constraint.If this is the case then why it is erroring out?
    please clarify this.

    Davide:
    By default, when you create a unique constraint, Oracle creates a unique index to enforce the constraint. In this case, duplicates are not allowed in the index itself.
    SQL> CREATE TABLE t (id number, descr VARCHAR2(10));
    Table created.
    SQL> ALTER TABLE t ADD CONSTRAINT t_unq UNIQUE (id);
    Table altered.
    SQL> SELECT index_name, uniqueness FROM user_indexes
      2  WHERE table_name = 'T';
    INDEX_NAME                     UNIQUENES
    T_UNQ                          UNIQUE
    SQL> SELECT constraint_name, constraint_type FROM user_constraints
      2  WHERE table_name = 'T';
    CONSTRAINT_NAME                C
    T_UNQ                          USince Oracle can and will use an existing index to enforce a unique constraint, when you pre-create the index as non-unique, it will be used to enforce the constraint. Since the index itself is not unique, duplicates are allowed in it.
    Note that a unique index by itself does not imply a unique constraint on the table.
    SQL> ALTER TABLE t DROP CONSTRAINT t_unq;
    Table altered.
    SQL> CREATE UNIQUE INDEX t_unq ON t(id);
    Index created.
    SQL> SELECT index_name, uniqueness FROM user_indexes
      2  WHERE table_name = 'T';
    INDEX_NAME                     UNIQUENES
    T_UNQ                          UNIQUE
    SQL> SELECT constraint_name, constraint_type FROM user_constraints
      2  WHERE table_name = 'T';
    no rows selectedSo, in a sense, with a unique index, it is the index itself which is constrained unique, not the table,
    HTH
    John

  • ENABLE NOVALIDATE

    Hi ALL,
    I have a table app_news_likee.
    Column Name     ID     Pk     Null?     Data Type     Default     Histogram     Encryption Alg     Salt
    TITLE     1          Y     VARCHAR2 (2000 Char)          Yes          
    CONTENT     2          Y     VARCHAR2 (2000 Byte)          Yes          
    START_DATE     3          Y     DATE          Yes          
    END_DATE     4          Y     DATE          Yes          
    CREATED_BY     5          Y     VARCHAR2 (8 Byte)          Yes          
    CREATED_TS     6          Y     DATE          Yes          
    NEWS_LINK     7          Y     VARCHAR2 (100 Byte)          Yes          
    NEWS_URL     8          Y     VARCHAR2 (256 Byte)          Yes          
    BANNER     9          Y     CHAR (1 Byte)          Yes     
    I would like to modify the column BANNER to varchar2(1BYTE) instead of CHAR (1 Byte) without affecting the existing records.
    I tried
    alter table app_news_likee modify BANNER VARCHAR2(1BYTE) ENABLE NOVALIDATE;
    It errored out saying : missing keyword
    Am I missing something here?
    Appreciate your help!
    Thanks in advance!
    BM

    your constraint modification should be seperate from your column modification:
    SQL> create table xyz (
      2  banner char(1) ,
      3  constraint check_xyz check (banner in ('X','Y','Z'))
      4  )
      5  /
    Table created.
    SQL>
    SQL>
    SQL> alter table xyz modify BANNER VARCHAR2(1)
      2  /
    Table altered.
    SQL>
    SQL> alter table xyz modify constraints check_xyz enable novalidate
      2  /
    Table altered.Edited by: bluefrog on Mar 4, 2010 3:06 PM

  • How can I enable a constraint even ORA-00054

    Dear,
    ALTER TABLE CLC_TRM_DTS_ATRBT
    MODIFY CONSTRAINT CLC_TRM_DTS_ATRBT_02_FK ENABLE;
    ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired.
    Any way to enable the constraint even any uncommited session or locked?
    Regards

    It is possible, for a busy database, that you will NEVER get the lock you need to enable the constraint. Just because one transaction finishes does not mean that another has not already started. Even a loop as Mr Chitale suggests may never succeed.
    The answer is to quiesce the database with ALTER SYSTEM QUIESCE RESTRICTED. It will hang until all active sessions have committed while preventing inactive sessions from waking up. Then kick off your ENABLE command, and in another session UNQUIESCE. This can be very quick, and your users may not even notice: their sessions will just appear to hang for a couple of seconds.
    John Watson
    Oracle Certified Master DBA

  • ALTER TABLE privilege and CREATE/DROP/ENABLE/DISABLE constraint privilege

    Hi,
    I am looking for some detailed info regarding the below previleges
    ALTER TABLE, CREATE CONSTRAINT, DROP CONSTRAINT, ENABLE CONSTRAINT AND DISABLE CONSTRAINT PRiVILEGES.
    I have two schemas 'A' and 'B', I want to provide user 'A' with Alter table, create or drop constraint,Enable or Disable constraint on schema B.
    Please let me know how to make this work.
    Thank you

    I got the answer for my second question, I have an option to grant 'Alter ANY table' privilege to the user.Yes, but you should not do that.
    Regarding question one, Suppose I have two schemas A and B and I want Schema A to have alter table privilege on all tables of Schema B.
    Can I do this in one command No
    or I need to grant alter on each table saperately?Yes
    If I am chosing the second option for each table saperately then whenever a table is added in schema B we need to grant privilege on that table as well.Yes. But nothing strange there. Designing and creating objects includes the privileges on them.
    If user A is granted with alter table privilege on a table which user B owns then can user A drop/create/enable/disable constraints for that table?Yes, isn't that what all this about?
    Again, letting one user alter the objects of another user is generally not such a good idea. Hope you see this from our discussion.
    Alter table privilege includes adding and dropping columns. This is why I suggested writing a procedure that does exactly what you need. And then grant execute on that to A.
    The best thing of course would be NOT TO disable the constraints, they are probably there for a reason.
    I am currently handling an issue where one session doing this, deadlocks with another session doing only selects - From other tables, that is!
    Regards
    Peter

  • Paralell in enable unique constraint

    TO use the feature of EXCEPTION into when creating unique index, I run the folllwing command to enable a unique constraints:
    alter table TEST_DUP2 enable constraint UNQ_TEST_DUP2     
    using index tablespace EDWSALESINDEX nologging
    EXCEPTIONS into exceptions
    This will create the unique index and when duplicate uniqe key encountered, the command fails and store the rowid of the duplicating row to exceptions table.
    Now I want to run this commnad in parallel to enhance performance. I tried
    alter table TEST_DUP2 enable constraint UNQ_TEST_DUP2     
    using index tablespace EDWSALESINDEX nologging PARALLEL
    EXCEPTIONS into exceptions
    and I got SQL Error: ORA-00933: SQL command not properly ended.
    Can this be done, or are there any worka around ?
    I do not want create unique index explicitly as that does not have the EXCEPTION into feature.
    Thanks

    Here is an example for exceptions,
    SQL> create table e( a number);
    Table created.
    SQL> alter table add constraint a_uk unique(a);
    alter table add constraint a_uk unique(a)
    ERROR at line 1:
    ORA-00903: invalid table name
    SQL> alter table e add constraint a_uk unique(a);
    Table altered.
    SQL> alter table e modify constraint a_uk disable;
    Table altered.
    SQL> host
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Aman>d:
    D:\>cd oracle\product\11.1.0\db_1\RDBMS\ADMIN
    D:\oracle\product\11.1.0\db_1\RDBMS\ADMIN>exit
    SQL> @utlexcpt.sql
    SP2-0310: unable to open file "utlexcpt.sql"
    SQL> host dir utlex*
    Volume in drive C is VAIO
    Volume Serial Number is 54A5-8EF0
    Directory of C:\Documents and Settings\Aman
    File Not Found
    SQL> host dir utl*
    Volume in drive C is VAIO
    Volume Serial Number is 54A5-8EF0
    Directory of C:\Documents and Settings\Aman
    File Not Found
    SQL> hist
    SP2-0042: unknown command "hist" - rest of line ignored.
    SQL> host
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Aman>d:\oracle\product\11.1.0\db_1\RDBMS\ADMIN
    'd:\oracle\product\11.1.0\db_1\RDBMS\ADMIN' is not recognized as an internal or extern
    operable program or batch file.
    C:\Documents and Settings\Aman>cd d:\oracle\product\11.1.0\db_1\RDBMS\ADMIN
    C:\Documents and Settings\Aman>sqlplus aman/aman
    SQL*Plus: Release 11.1.0.6.0 - Production on Mon Sep 15 22:02:20 2008
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the Partitioning, Oracle Label Security, OLAP, Data Mining,
    Oracle Database Vault and Real Application Testing options
    SQL>
    SQL> d:\oracle\product\11.1.0\db_1\RDBMS\ADMIN
    SP2-0734: unknown command beginning "d:\oracle\..." - rest of line ignored.
    SQL> @d:\oracle\product\11.1.0\db_1\RDBMS\ADMIN\utlexcpt.sql
    Table created.
    SQL> insert into e values(1);
    1 row created.
    SQL> /
    1 row created.
    SQL> /
    1 row created.
    SQL> alter table e modify constraint a_uk  enable validate exceptions into exceptions;
    alter table e modify constraint a_uk  enable validate exceptions into exceptions
    ERROR at line 1:
    ORA-02299: cannot validate (AMAN.A_UK) - duplicate keys found
    SQL> select * from exceptions;
    ROW_ID             OWNER                          TABLE_NAME
    CONSTRAINT
    AAARXIAAGAAAAAVAAC AMAN                           E
    A_UK
    AAARXIAAGAAAAAVAAB AMAN                           E
    A_UK
    AAARXIAAGAAAAAVAAA AMAN                           E
    A_UK
    SQL> select * from exceptions;Its on 11106.The same must work on pre 11g also.Do this and let me know.
    Yup,Parallel is unimplemented surely enough,
    SQL> alter table e
      2  enable validate constraint a_uk using index  tablespace nologging parallel;
    enable validate constraint a_uk using index  tablespace nologging parallel
    ERROR at line 2:
    ORA-03001: unimplemented featureAnd here is the reason for it,
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_3001.htm#i2054940
    The clause Parallel is not a right clase for this command.
    Hope this helps
    Aman....
    Edited by: Aman.... on Sep 15, 2008 10:08 PM

  • Enable/disable constraint

    Hi!
    Kindly help.
    I'm using 9207 on win server 2k3.
    I have a master table with 100M records, I need to retain only 10M of data. I plan to put the 10M of data to be retained to a temp table, I truncate the master table, then I put the 10M of data from the temp table back to the master table. I will use the parallel and nologging for the index and table and I'll use the skip_unusable_index option. Is it ok to disable the constraints? After the bulk load I'll still be able to enable them correct?
    I'm just worrying that I might not be able to enable the constraints.
    Thanks and Best REgards
    Dexter

    You can disable the constraints before the operation and enable them afterwards. It will not be a problem unless you insert invalid data not matching your constraints.
    You can insert the rows you want into a new table, create indexes and constraints and then rename that table. This way you do not need to reinsert the rows back to the original table from the temp table.

  • Estimate time to enable all constraints and create all indexes

    Hi,
    To prepare a project to export/import for a whole database,
    How can I estimate time required to enable all constraints and create all indexes
    * Assume one full table scan per one FK constraint
    * Assume one full table scan plus one sort/merge operation per one index
    * Check it out whether we can use parallel DDL feature to speed up enabling of FK constraints
    how can I use core schema (which will be exp/imp) in the production db to get needed metric for the calcualtion?
    thanks
    Jerry

    There is no definative way to find the time it takes to enable a constraint / create a Index
    It toatally depends on the Size of the table / execution plan / resources available (In terms of CPU and Physical Memory ) /
    Amount of Temporary tablespace

  • Variant configuration constraint syntax

    hi everybody
    i have product A and B. B is subassembly of A. class for A is A_class and for b is B_class. class of B is attached to the class of A.both are configurable materials. there are four characteristics of B char1, char2,char3,char4 all these contains five same values like val1,val2,val3,val4 and val5.
    these characteristics are there in  A also (these characteristics are common for both) .
    Now at the time of configuration of A whatever the values i enter for these common characterstics these should be copied to the characteristics of B.
    how can i write the constraints syntax in this situation pls suggest.
    thanks and reagards
    ramakant

    Hi Ramakant...,
    Create the Dependency Net in Cu21. and write a constrain like this
    Objects:
    X IS_A(300) A_CLASS,
    Y IS_A(300) B_CLASS,
    RESTRICTIONS:
    X.CHAR1 = Y.CHAR1,
    X.CHAR2 = Y.CHAR2,
    X.CHAR3 = Y.CHAR3,
    X.CHAR4 = Y.CHAR4,
    X.CHAR5 = Y.CHAR5,
    INFERENCES:
    Y.CHAR1,
    Y.CHAR2,
    Y.CHAR3,
    Y.CHAR4,
    Y.CHAR5.
    in the configuration if you assign a value to characteristics of A_class then automatically Class of B_class wil get the value.
    if you want the exact syntax give the real data and i will write the syntax.
    regards.

  • Error in enabling constraints

    Hi everybody,
    i have 2 databases d01 and d02. i have same no and same objects on both the databases.
    i am exporting data for 1 subscriber from d01 and importing into d02.during importing data to d02 first i disable all constraints of the tables in d02 then importing the data which i have exported from d01 then i am enabling the constraints in d02.
    my problem is that at the time of enabling the data i have encountered some errors as follows.
    Error while Alter Table PORTFOLIO_CRITERIA_CONDITIONS enable novalidate
    constraint XFK3PRTF_CRITERIA_CONDITIONS
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Error while Alter Table PORTFOLIO_CRITERIA_CONDITIONS enable novalidate
    constraint XFK3PRTF_CRITERIA_CONDITIONS
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Error while Alter Table PORTFOLIO_CRITERIA_CONDITIONS enable novalidate
    constraint XFK3PRTF_CRITERIA_CONDITIONS
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Error while Alter Table PORTFOLIO_TYPE2ATTRIBUTE enable novalidate constraint
    XFK12PORTFOLIO_TYPE2ATTRIBUTE
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Error while Alter Table PORTFOLIO_TYPE2ATTRIBUTE enable novalidate constraint
    XFK12PORTFOLIO_TYPE2ATTRIBUTE
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Error while Alter Table PORTFOLIO_TYPE2ATTRIBUTE enable novalidate constraint
    XFK12PORTFOLIO_TYPE2ATTRIBUTE
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Error while Alter Table PORTFOLIO_TYPE2ATTRIBUTE enable novalidate constraint
    XFK12PORTFOLIO_TYPE2ATTRIBUTE
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    PL/SQL procedure successfully completed.
    can u please tell me what is the error.
    Thanks and regards
    Subrata

    Hallo,
    i guess, that you use dynamic sql here, something like
    declare
    v_sql varchar2(30);
    begin
    v_sql := 'Alter Table PORTFOLIO_CRITERIA_CONDITIONS enable novalidate
    constraint XFK3PRTF_CRITERIA_CONDITIONS';
    execute immediate v_sql;
    Then, you have to increase the length of v_sql. It's too small !
    Regards
    Dmytro

  • 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.

Maybe you are looking for