Oracle check constraint bug ?

Hi,
This is an 'interesting' bug:
create table mytable (
id number,
status number,
constraint mytable_pk primary key (id)
insert into mytable (id, status) values (1, 0);
insert into mytable (id, status) values (2, -1);
On XE (10.2.0.1) and 10.2.0.4:
Following command gives the expected ORA-02293 error (using string values instead of numbers): alter table mytable add constraint mytable_status_chk check (status in ('0', '1'));
BUT no error with the following command: alter table mytable add constraint mytable_status_chk check (status in ('-1', '0', '1'));
On XE:
The query select * from mytable where status=0 returns no records until the constraint is dropped again !
Best regards,
Serge
Edited by: sergeko on Nov 19, 2010 11:19 AM
Edited by: sergeko on Nov 19, 2010 11:21 AM

I don't have access to any 10.x or XE currently and cannot reproduce on EE 9.2.0.9 or 11.1.0.6.
It's possible that you're running into an optimizer issue with the constraint.
This might be visible if you run an explain plan on the statement, get the execution plan via dbms_xplan.display and check the predicates section both with and without the constraint.
I take it that you don't get the problem if you use a check constraint with numbers not strings.
I wonder also whether it makes a difference if you declare status as not null.
Edited by: DomBrooks on Nov 19, 2010 10:44 AM

Similar Messages

  • 10g 10.2.0.1.0 - Check Constraint with negative values possibly BUG.

    Hello,
    Why this doesn't work ?
    create table a (b numeric(1));
    alter table a
    add constraint b CHECK (b in (0, 1, -1)) ENABLE;
    select * from a where b = -1;
    I get the following error: java.sql.SQLException: No more data to read from socket
    - Through the jdbc client. It happens with the Oracle Client too.
    When i change my check constraint to this:
    alter table a
    add constraint b CHECK (b in (-1, 0, 1)) ENABLE;
    It works.
    It's a (known) bug ?
    Regards,
    Francisco

    hi dear,
    I want to upgrade my OMS server 10.2.0.1 to 10.2.0.5
    I downloaded the patch 10.2.0.5 and read the README.txt
    Part of the README is:
    1.2 Enter the following command to extract the installation files:
    $ unzip GridControl_10.2.0.5_<platform name>.zip
    This command extracts the following files and directory:
    |- p3731593_10205_<platform name>.zip
    |- 3731596.zip
    |- 3822442.zip
    |- README.txt
    |- doc/
    NOTE: <platform name> will be "LINUX" or "Win32" depending on the platform for which you are installing. For installing Enterprise Manager 10g Grid Control Release 5 (10.2.0.5), refer to the Release Notes available in the "doc" directory.
    - p3731593_10205_<platform name>.zip is the ZIP file that contains 10.2.0.5 patch set software.
    This zip can be used for:
    - Upgrading Oracle Management Service Release 2 (10.2.0.x) or higher to Oracle Management Service Release 5 (10.2.0.5)
    - Upgrading Oracle Management Repository (sysman schema)
    - Upgrading Oracle Management Agent on the host where OMS is running.
    NOTE: This will not upgrade the database in which the Management Repository (sysman schema) resides.
    - 3731596.zip is for patching Management Agent by staging the patch set. To understand how you can apply the Management Agent 10.2.0.5 patch set, refer to method 2 described in section 4.3.3 "Upgrading Management Agent - Multiple Hosts at a Time" of the Release Notes. The Release Notes can be found in the "doc" directory.
    - 3822442.zip is for patching Management Agent by distributing the full patch set.  To understand how to apply the Management Agent 10.2.0.5 patch set, refer to method 1 described in section 4.3.3 "Upgrading Management Agent - Multiple Hosts at a Time" of the Release Notes. The Release Notes can be found in the "doc" directory.3731596.zip - by staging
    3822442.zip - by distributing
    Does the two above have the same function or purpose?
    I can not understand the meaning of the two :( . which do you think is the right one for my setup?
    Thanks a lot

  • Peculiar problem in oracle 10g  on AIX 5.3.0 With Check constraints

    Hi Every One,
    I am facing peculiar problem in oracle 10.2.0.1.0,AIX 5.3.0. I created table with check constraints like this
    create table test1 (name nvarchar2(1),check (name in('Y','N')));
    SQL> create table test1 (name nvarchar2(1),check (name in('Y','N')));
    Table created.
    SQL> insert into test1 values ('Y');
    1 row created.
    SQL> COMMIT;
    SQL> select from test1 where name = 'Y';* Why this statement is n't working
    no rows selected
    SQL> select * from test1;
    N
    Y
    ANOTHER INTERSTING ONE IS
    SQL> select * from test1 where name in('Y'); Why this statement is n't working
    no rows selected
    SQL> select * from test1 where name in('Y','Y'); it's working
    N
    Y
    SQL> select * from test1 where name in('','Y'); it's working
    N
    Y
    SQL> select * from test1 where name in('7','Y'); it's working
    N
    Y
    Like
    SQL> select * from test1 where name like 'Y'; it's not working
    no rows selected
    I created a table without check constraints
    SQL> create table test2 (name nvarchar2(1));
    Table created.
    SQL> insert into test2 values ('Y');
    1 row created.
    SQL> select * from test2;
    N
    Y
    SQL> select * from test2 where name ='Y'; it's working
    N
    Y
    SQL> select * from test2 where name like 'Y'; it's working
    N
    Y
    Database Details
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET WE8MSWIN1252
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    PARAMETER VALUE
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 10.2.0.1.0
    Why it's happening. Whehter check constraint is valid or not in Equallity operator and like and in .
    Whereever we using single character column with check constraint,it's working with Equality operator and like and in.
    IT'S WORKING FINE WITHOUT CHECK CONSTRAINTS.WE HAVE TWO AIX MACHINES WITH ORACLE10G.THE SAME PROBLEM OCCURING IN TWO MACHINES
    PLEASE HELP ME .
    THANK YOU,
    WITH REGARDS,
    N.VINODH

    h
    Edited by: user3266490 on Dec 3, 2008 2:30 AM

  • Crash of Oracle XE when check constraint uses in-operator with desc. values

    ORA-03113 and other errors in conjunction with lost of connection occur in Oracle XE under the following conditions:
    /* Crash (values of check constraint in descending order) */
    DROP TABLE CRASHTEST CASCADE CONSTRAINTS;
    CREATE TABLE CRASHTEST
    CRASHTEST_ID NUMBER(9),
    CRASHTEST_OK NUMBER(1) DEFAULT 0
    ALTER TABLE CRASHTEST ADD (CONSTRAINT CRASHTEST_CK CHECK (CRASHTEST_OK IN (0,-1)));
    INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (1, 0);
    INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (2, -1);
    COMMIT;
    SELECT * FROM CRASHTEST WHERE CRASHTEST_OK = 0;
    If all values of the in-clause within the check constraint are entered in ascending order, no error occurs:
    /* No Crash (values of check constraint in ascending order) */
    DROP TABLE CRASHTEST CASCADE CONSTRAINTS;
    CREATE TABLE CRASHTEST
    CRASHTEST_ID NUMBER(9),
    CRASHTEST_OK NUMBER(1) DEFAULT 0
    ALTER TABLE CRASHTEST ADD (CONSTRAINT CRASHTEST_CK CHECK (CRASHTEST_OK IN (-1,0)));
    INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (1, 0);
    INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (2, -1);
    COMMIT;
    SELECT * FROM CRASHTEST WHERE CRASHTEST_OK = 0;
    Especially interesting is the fact, that the error is caused by a check constraint in conjunction with a select statement!
    Hopefully, there are no other hidden bombs stealing my time...
    Have a nice day,
    Sven

    It might be interesting to post that in the XE forum to notify Oracle developers and XE users.
    Oracle Database Express Edition (XE)
    C.

  • 10g R2 NVARCHAR2 check constraint problems

    Hi, Thanks for taking a look...
    I've just installed 10g R2 on Solaris 10 and run into a small problem with NVARCHAR2s.
    I have a table with a check constraint to make sure the column is a valid value on an nvarchar2 column. Querying the table for a specific value results in no data found, however the data appears to be intact.
    The database NLS_CHARACTERSET is AL32UTF8 and NLS_NCHAR_CHARACTERSET is AL16UTF16.
    I think the following script results can show the problem better than I can explain it.
    Any suggestions would be appreciated. Thanks.
    Mike
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Apr 17 13:51:40 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning and Data Mining options
    SQL> @problem_script.sql
    SQL> create table foo (
    2 bar nvarchar2(10) constraint ck_bar check (bar in ('abc','def'))
    3 );
    Table created.
    SQL> insert into foo values ('abc');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> REM Strange. This worked in every version prior to 10g R2.
    SQL> REM Why doesn't it work now?
    SQL>
    SQL> select * from foo where bar = 'abc';
    no rows selected
    SQL>
    SQL> REM Even more strange is why this doesn't work:
    SQL>
    SQL> select * from foo where bar = N'abc';
    no rows selected
    SQL>
    SQL> REM Stranger still are these two queries:
    SQL>
    SQL> select bar, decode(bar, 'abc', 'It matches', 'No it doesnt')
    2 from foo;
    BAR DECODE(BAR,'A
    abc It matches
    SQL>
    SQL> REM This is still strange, but not unexpected given the prior query
    SQL>
    SQL> select bar, decode(bar, 'abc', 'It matches', 'No it doesnt')
    2 from foo
    3 where bar = 'abc';
    no rows selected
    SQL>
    SQL> REM Strangest of all is why this DOES work:
    SQL>
    SQL> alter table foo disable constraint ck_bar;
    Table altered.
    SQL> select * from foo where bar = 'abc';
    BAR
    abc
    SQL>
    SQL>
    SQL> REM Regular varchars are unchanged...
    SQL>
    SQL> create table bar (
    2 foo varchar2(10) constraint ck_foo check (foo in ('abc','def'))
    3 );
    Table created.
    SQL> insert into bar values ('abc');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from bar where foo = 'abc';
    FOO
    abc

    Nope.
    SQL> select * from foo where bar = TO_NCHAR('abc');
    no rows selected
    Of all the things I've tried (and I think I've tried just about everything), only the TO_CHAR(bar) and disabling the check constraint work. The fact that DECODE(bar, 'abc', 'true', 'false') in the select list is also confusing since it's converted there correctly, but not in the WHERE clause. And why does it work as epxected when the constraint is disabled?
    My thoughts are that it can't be an Oracle bug, otherwise I'm sure I wouldn't be the first to find it. I've built the instance using the same configuration script I used for the 10g R1 database that works, so the configuration parametes are the same.
    More things that don't make sense:
    SQL> select dump(bar), dump('abc') from foo;
    DUMP(BAR)
    DUMP('ABC')
    Typ=1 Len=6: 0,97,0,98,0,99
    Typ=96 Len=3: 97,98,99
    SQL> select dump(bar), dump(to_nchar('abc')) from foo;
    DUMP(BAR)
    DUMP(TO_NCHAR('ABC'))
    Typ=1 Len=6: 0,97,0,98,0,99
    Typ=1 Len=6: 0,97,0,98,0,99
    Thanks for your help though...
    Mike

  • How to use external functions in check constraints

    I created my own function:
    create or replace
    function if_num_get_num (inval in varchar2)
    return number
    is
    dummy number;
    Begin
    dummy := to_number(inval);
    return dummy;
    exception
    when others then return null;
    end;Can I use it in table check constraint?
    When I use standard function INSTR everything is OK.
    ALTER TABLE A_S
    ADD CONSTRAINT A_S_CHK1 CHECK
      (INSTR(NAZWA_ZA, ':') > 0)
    ENABLE;but when I try to create it with my function:
    ALTER TABLE A_S
    ADD CONSTRAINT A_S_CHK1 CHECK
      (IF_NUM_GET_NUM(INSTR(NAZWA_ZA, ':')) > 0)
    ENABLE;I get a message "Invalid column IF_NUM_GET_NUM"

    Read the restrictions.
    >
    Restrictions on CHECK Constraints
    A CHECK constraint requires that a condition be true or unknown for every row of the table. If a statement causes the condition to evaluate to false, then the statement is rolled back. The condition of a CHECK constraint has these limitations:
    * The condition must be a boolean expression that can be evaluated using the values in the row being inserted or updated.
    * The condition cannot contain subqueries or sequences.
    * The condition cannot include the SYSDATE, UID, USER, or USERENV SQL functions.
    * The condition cannot contain the pseudocolumns LEVEL or ROWNUM.
    * The condition cannot contain the PRIOR operator.
    ** The condition cannot contain a user-defined function.*
    >
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17125/adfns_constraints.htm#ADFNS282

  • Check Constraint names aren't synced when engineering to logical

    Just learned about this tool at OOW and ran into an issue involving check constraint names being compared but not synced when engineering from the relational model to the logical model. When I set the constraint names in the logical model (and perform one last "Engineer to Logical Model") after that the compare dialog shows the table and entities match. Is this a bug?
    Steps to reproduce:
    1. importing a relational data model from data dictionary which contains a table with a column level check constraint
    2. perform "Engineer to Logical model" to produce the logical model
    Issue:
    Perform another "Engineer to Logical model" which will show the table with the column level check constraint as being out of sync with the logical model's equivalent entity, when you drill down into the diff in the compare dialog box you see the check constraint name has a value in the relational model and the name is null in the logical model
    Verify:
    Looking in logical model at the constraint (<Entity>/Attributes/Attribute Properties/Default and Constraint/Constraint Name) the value is empty
    Work Around:
    Set the constraint name in the spot from verify above and perform "Engineer to Logical model" twice. The first time it will show the same issue, the second time it will show the table and entity match

    Hi Bo,
    thanks for feedback. It's fixed now and you'll get the fix in version 3.0.
    Another( probably better workaround) - in engineering dialog - "Compare/Copy options" tab - uncheck "Don't use for new objects" option.
    Philip

  • Max number of CHECK constraints on a column in Oracle9i?

    What is the maximum number of CHECK constraints that can be defined on a column when creating a table in Oracle 9i database?
    Also could some one tell me what are the limitations on CHECK constraints?

    Well, in Oracle 8.1.7 documentaion it is stated that number of constraints is also unlimited. I haven't such a database now to test but here is a little test for Oracle 9iR2
    SQL> drop table test;
    Table dropped.
    SQL> create table test (a number
      2   check (a > 1)
      3   check (a > 2)
      4   check (a > 3)
      5   check (a > 4)
      6   check (a > 5)
      7   check (a > 6)
      8   check (a > 7)
      9   check (a > 8)
    10   check (a > 9)
    11   check (a > 10)
    12   check (a > 11)
    13   check (a > 12)
    14   check (a > 13)
    15   check (a > 14)
    16   check (a > 15)
    17   check (a > 16)
    18   check (a > 17)
    19   check (a > 18)
    20   check (a > 19)
    21   check (a > 20)
    22  )
    23  /
    Table created.

  • Check constraint generation in physical model in 3.1.1.

    My question: Is it possible to set Use Domain Constraints ticked as default (or another way to get them in DDL) if the Domain with Check constraint is set for the column. I assume it's logical as if I bind a column to the domain then use the domain constraint as default policy. It's not a big deal if you have a few but in my case I do re-modelling just for physical model level and I have tens column in the tables based on a domain. So, I have first to set the domain as a column type and then in another screen tick Use Domain Constraints
    Thank you

    Hi,
    Is it possible to set Use Domain Constraints ticked as default (or another way to get them in DDL) if the Domain with Check constraint is set for the column.No it's not possible I logged bug for that.
    So, I have first to set the domain as a column type How do you set domain as data type? Do you have more than one columns using the same domain? In such cases you can use domain dialog (in the browser) and "Used in" page in order to assign domain to several columns/attributes at once.
    You can use the script below to set use domain constraints on columns that use domain as data type
    Philip
    var model;
    tables = model.getTableSet().toArray();
    for (var t = 0; t<tables.length;t++){
    table = tables[t];
    columns = table.getElements();
    for (var i = 0; i < columns.length; i++) {
         column = columns;
         if(column.getUse() == 0 && column.getDomain()!=null){
              if(!column.getUseDomainConstraints()){
                   column.setUseDomainConstraints(true);
                   table.setDirty(true);

  • Problem with check constraint in mysql

    I am using mysql v8.14 and I have a problem on CHECK which is given below. I want to insert just 'friends' and 'all' on privacy attribute
    but mysql inserts everything.
    Can anyone help me, please? Thanks
    CREATE TABLE `customer`
    `cid` NUMERIC(6),
    `cname` VARCHAR(25),
    `password` VARCHAR(6),
    `email` VARCHAR(25),
    `phone` NUMERIC(12),
    `privacy` VARCHAR(10),
    PRIMARY KEY (`cid`),
    CHECK (`privacy`= `friends` OR `privacy`= `all`)
    );

    I am not familiar with MySQL syntax, but I would offer this observation:
    In your definition of the check constraint:
    CHECK (`privacy`= `friends` OR `privacy`= `all`)you are using the same delimiters (`) around both your column names and your literals. Is that correct?
    i.e. in Oracle I would use
    CHECK(privacy = 'friends' OR privacy = 'all')because privacy is not a literal, it is a column name.
    Is your syntax correct?

  • Problem in creating CHECK constraint

    While creating a table, i want to apply a CHECK constraint, that pension_amount should be in accordance of pension_code, i am getting error mentioned below.
    CREATE TABLE pension_amount_check
       pension_amount         NUMBER (4),
       pension_code   NUMBER (1),
       CONSTRAINT amount_chk CHECK
          (CASE
              WHEN pension_code = 1 THEN (pension_amount = 3000 OR pension_amount > 3000)
              WHEN pension_code = 2 THEN pension_amount = 1500
           end)
    ORA-00907: missing right parenthesisHow i can resolve this.

    CREATE TABLE pension_amount_check
       pension_amount         NUMBER (4),
       pension_code   NUMBER (1),
       CONSTRAINT amount_chk CHECK
             (pension_code = 1 AND pension_amount  >= 3000)
              OR
             (pension_code = 2 AND pension_amount  = 1500)
    )http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17125/adfns_constraints.htm#ADFNS282

  • How can i modify the check constraint   in the table

    How can i modify the check constraint in the table. This table containts check constraint, condition is code_value between 1 and 4. codevalue is column name.
    Please suggest me.

    Go to tahiti.oracle.com, pick version browse reference manual and see the alter table statement
    Also read the goal of this forum.
    Your question is more appropriate to Database general forum
    General Database Discussions
    Gints Plivna
    http://www.gplivna.eu

  • Displaying an error message  coused by check constraint

    Hi,
    I'm trying to replace oracle error message by my own message.
    Form report is throwing an expected error like :
    'Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-02290: check constraint ...'
    I used the plsql block to handle with that but it doesnt set the my message. After press a button the check constraint validate a date and if data are unexpected then throwing a error which i want to replace by my own.
    The process is listed below:
    DECLARE
    invalid_sql EXCEPTION;
    PRAGMA EXCEPTION_INIT (invalid_sql, -02290);
    page_error EXCEPTION;
    PRAGMA EXCEPTION_INIT (page_error, -20001);
    BEGIN
    :p12_error := NULL;
    EXCEPTION
    WHEN invalid_sql THEN
    :p12_error := 'In case of sql injection attack some of the statements were forbidden: INSERT, UPDATE, DELETE, DROP, ALTER, TRUNCATE, EXECUTE';
    WHEN page_error THEN
    :P12_ERROR := 'Please contact your administrator !!!';
    WHEN OTHERS THEN
    :p12_error := SQLERRM;
    END;
    P12_ERROR -- hidden item
    Then i set the 'success message ' :
    &P12_ERROR.
    What is wrong that is not showing my message?It not recognoze Init pragma?.
    Please give my some points on it!
    Edited by: rafix on 2008-12-16 04:31

    I followed Denes Kubick' way on his blog http://htmldb.oracle.com/pls/otn/f?p=31517:185:17139524101939:::RP,::
    where he created process on SubmitThe process is a simple example of error handling in ApEx. It does inserting and at the
    same time it handels exceptions. If an exception occurs, it will use a hidden item on the
    page to store error messages. At the same time, the success message of that process
    (which is what you get after pressing the "Save" button) is &P185_ERROR. item.
    Returning to my previous post i got tabular form report where constraint makes error in case of writing 'insert, delete...' after save button where have been pressed. Pragma mechenism is trapping like you wrote exceptions.Ok.
    So what i need configure to associate that process to trapped error?
    Edited by: rafix on 2008-12-17 05:40

  • Difference between a check constraint and a trigger

    Hi, I wanted to know the exact usage of a trigger within a database.
    Suppose I want to have a restriction on an insert into a Employees table that provides a check on the time that a particular employee signs in,
    I could do that with the help of a before insert trigger that prevents certain values fgrom being inserted.
    But cant I do the same thing with the help of a simple check constraint?
    Where exactly does the distincton lie between a constraint and a trigger?
    Edited by: user8680847 on Sep 24, 2009 11:55 PM

    A trigger is fired due to DML operations(Insert,Update,Delete) ot on Database events like startup, shutdown etc. You can write your piece of logic into the trigger to do the necessary operations when the event occurs.
    For example, if you want you track the changes made to +(emp)+ table data you can place a before update trigger on the table and place your code inside the triiger to insert the old values into an audit table +(emp_audit)+. Everytime an update is made on the table data the trigger will get fired and will insert the old values of the record into the audit table and the new value in the +(emp)+ table.
    A constraint is completely different from a trigger. A constraint is like a validation on the data to be inserted. There are different types of constraints.
    I will give you a simple example.
    You place the not null constraint on the dept column of the emp table. While you try to insert a new record into the emp table the the dept value cannot be null. Oracle will validate the data you are trying to insert into the table with the constraint and will give you an error if the validation fails.
    There are other constraints like:
    unique key
    foreign key
    etc.
    Precisely a constraint does not handle a database event as a trigger rather it validates the column data.
    Edited by: Priyabrat on Sep 25, 2009 12:27 AM

  • Invalid check constraint - cleaning up

    Hi,
    Is there a way to get rid of an invalid check constraint after attempting to add it to a Workspace Manager enabled table?
    If I do the following on Oracle 10.2.0.1:
    create table table1 ( id number(20) not null, data varchar2(50), primary key (id));
    exec dbms_wm.enableversioning('TABLE1');
    insert into table1 values ( 1, 'a' );
    exec dbms_wm.beginddl('TABLE1');
    alter table table1_lts add check ( id > 1);
    exec dbms_wm.commitddl('TABLE1');
    I get "cannot validate (BR.SYS_C00580318) - check constraint violated", which is expected. However, at this point the table1_lts is gone so the ddl operation cannot be rolled back. If I retry the commit, ignoring errors:
    exec dbms_wm.commitddl('TABLE1',TRUE);
    the ddl operation completes, but the check constraint is still present in user_wm_constraints. If I then do the following:
    exec dbms_wm.beginddl('TABLE1');
    exec dbms_wm.commitddl('TABLE1');
    I get "cannot validate (BR.SYS_C00580318_LTS) - check constraint violated" so it appears to retry adding the invalid constraint. I've also tried dropping the constraint again during the second ddl operation. This prevents the second error but the constraint still hangs around in user_wm_constraints.
    One thing I might be missing is some sort of cleanup step, after the first commitddl, that would get rid of the constraint completely. Is there some sort of extra operation I should be doing at this point?

    Hi,
    The metadata is out of sync because of the statement that got skipped during the initial commitDDL. This can be fixed by verifying that the constraint does not exist on the _LT table and then executing the following while logged in as someone with system privileges:
    SQL> delete wmsys.wm$constraints_table where owner='<versioned_table_owner>' and constraint_name='<user_defined_constraint>' ;
    We can add a check to verify the constraint during commitDDL to prevent this situation in the future.
    Regards,
    Ben

Maybe you are looking for