I'm trying to put a Check constraint on a born date in a range of date time because I don't want to let the user insert a value < of 01-JAN-1900.
I'm trying to elabourate this as :
CONSTRAINT BORN_VALIDITY CHECK(BORN_DATE > TO_DATE('01-GEN-1900','DD-MON-1900'));
I also altered the date format session in the beginning with
ALTER SESSION NSL_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
but I'm receiving the same error with no pity from Oracle SQL.
There is some other way to set a date range on my check constraint?
Assuming that the language of your DB is Italian, or whatever language in which you can write January as GEN, you should use TO_DATE('01-GEN-1900','DD-MON-YYYY')
.
To have a solution that works no matter the language, you could better use the ANSI standard date '1900-01-01'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.