Add Check Constraint Error
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Add Check Constraint Error

  1. #1
    Join Date
    Jan 2004
    Posts
    30

    Add Check Constraint Error

    Hi all,
    I had encounter below error when I trying to add check constraint in my existing table. Any ideal to get rid of the error?
    thanz in advance.
    SQL> l
    1 alter table table1 add contraint
    2* chk_1 check (col1 in ('Y','N'))
    SQL> /
    chk_ 1 check (col1 in ('Y','N'))
    *
    ERROR at line 2:
    ORA-02438: Column check constraint cannot reference other columns

  2. #2
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758

    Re: Add Check Constraint Error

    Originally posted by samc
    Column check constraint cannot reference other columns
    Yes, that is the answer.
    Sanjay G.
    Oracle Certified Professional 8i, 9i.

    "The degree of normality in a database is inversely proportional to that of its DBA"

  3. #3
    Join Date
    Apr 2003
    Posts
    353
    May be the column not part of the table or column name typed wrong.

    SQL> create table kk ( no number(5));

    Table created.

    SQL> alter table kk add constraint xcv check (no in(1,2));

    Table altered.

  4. #4
    Are you sure you really want check constraints? Personally I hate the damn things. Every time our developers add a new possible value to the code they then forget theres a check constrain and it sll stops working. Data-driven validation every time!

  5. #5
    Join Date
    Feb 2004
    Posts
    1
    Hi,

    SQL> create table sjk (name varchar2(5));

    Table created.

    SQL> alter table sjk add constraint cs check (name in ('Y','N'));

    Table altered.

    Regards,
    Shirish

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width