SQL oracle add check constraint to an existing table
Your constraint looks right, I have tested it:
create table appeal ( OpenDate date, CloseDate date);alter table appealadd constraint Check_Datescheck (OpenDate < CloseDate);insert into appeal values ( sysdate, sysdate - 1 );
And here the result:
Schema Creation Failed: ORA-02290: check constraint (USER_4_44096.CHECK_DATES) violated
Problem is than you have already rows with OpenDate < CloseDate values in your database. Fix it before create constraint. Look behavior changing sentences order:
create table appeal ( OpenDate date, CloseDate date);insert into appeal values ( sysdate, sysdate - 1 );alter table appealadd constraint Check_Datescheck (OpenDate < CloseDate);
And here your issue:
Schema Creation Failed: ORA-02293: cannot validate (USER_4_E4450.CHECK_DATES) - check constraint violated