CHECK (expiry_date > sysdate)

You can’t use SYSDATE within CHECK condition. SYSDATE it is a pseudo-column function. A function is supposed to return a value and this is not how CHECK constraint was designed.  With CHECK constraint you can only use explicit column values or literals. CHECK won’t do any function calls from inside. Therefore the statement below would fail.

 

 

Same is true about other non-deterministic functions such as SYSDATE, DBTIMEZONE, SYSTIMESTAMP, ROWID, ROWNUM, UID, USER, LEVEL, CURRVAL, NEXTVAL, ORA_ROWSCN, etc. You can’t use any of those within CHECK constraint

You also can’t use CURVAL or NEXTVAL of a sequence

Using a column name from different table is also forbidden with CHECK constraint

 

 

One thought on “CHECK (expiry_date > sysdate)”

Leave a comment

Your email address will not be published. Required fields are marked *