SQL Check Constraint cannot reference other column

Posted by user1777711 on Stack Overflow See other posts from Stack Overflow or by user1777711
Published on 2012-11-06T04:01:51Z Indexed on 2012/11/06 5:00 UTC
Read the original article Hit count: 131

Filed under:
|

I trying to add this sql check in

ALTER TABLE School
add Role check_role
  CHECK (check_role IN ('Teaching Assistant', 'Lecturer', 'Professor'));

I get the error below

ERROR at line 3:
ORA-02438: Column check constraint cannot reference other columns

SQL> desc School;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------

 STAFFNUM                                  NOT NULL VARCHAR2(12)
 NAME                                      NOT NULL VARCHAR2(50)
 ADDRESS                                   NOT NULL VARCHAR2(300)
 DOB                                                DATE

I am trying add a column call Role, with the check constraint check_role

I am using Oracle SQL.

Thanks for all help!

© Stack Overflow or respective owner

Related posts about sql

Related posts about Oracle