footy
footy

Reputation: 5911

Cannot reference other columns Oracle SQL

Here is my table declaration for Oracle SQL.

create table students (
    sid char(4) primary key check (sid like 'B%'),
    firstname varchar2(15) not null,
    lastname varchar2(15) not null,
    status varchar2(10) check (status in (‘freshman’, ‘sophomore’, ‘junior’, ‘senior’, ‘graduate’)),
    gpa number(3,2) check (gpa between 0 and 4.0),
    email varchar2(20) unique
    );

Why does the following error occur

ORA-02438: Column check constraint cannot reference other columns

Upvotes: 1

Views: 143

Answers (1)

Egor Skriptunoff
Egor Skriptunoff

Reputation: 23747

Use single quotes: 'freshman',...

Upvotes: 3

Related Questions