Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Check Constraints

Re: Check Constraints

From: Tony Andrews <andrewst_at_onetel.com>
Date: 21 Jan 2005 07:29:36 -0800
Message-ID: <1106321376.752133.325380@c13g2000cwb.googlegroups.com>


If you carefully check the syntax diagrams in the SQL Reference you will find that your 1st attempt was invalid. You may do either of these:

ALTER TABLE <t> ADD CONSTRAINT <name> CHECK (COMMISSION > 0)

ALTER TABLE <t> ADD CHECK (COMMISSION > 0)

But you cannot use the keyword CONSTRAINT without specifying the constraint name. By its error message, Oracle appears to believe that you are trying to add a column called "CONSTRAINT" with an inline column check constraint referencing a different column. Change "CONSTRAINT" to "FOO" and you get the same result:

SQL> ALTER TABLE EMP
2 ADD foo
3 check (SAL > 0);
check (SAL > 0)
*
ERROR at line 3:
ORA-02438: Column check constraint cannot reference other columns Received on Fri Jan 21 2005 - 09:29:36 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US