Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Check Constraints
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