Question:
SQL Oracle 11g: Is this constraint valid for date/time?
anonymous
2012-08-09 01:31:38 UTC
I have to add a constraint so that sale_date cannot be in the future.

create table Sales
(
sale_date date default sysdate NOT NULL check (sale_date <= sysdate)
);
Three answers:
Lonely Rogue
2012-08-10 00:38:24 UTC
Logically its right... needs a little re-write for syntactical compliance.



CREATE TABLES Sales

(

Sale_date DATE DEFAULT SYSDATE NOT NULL

CONSTRAINT SaleDateValidator CHECK (sale_date <= sysdate)

);



That should work.



-- In 'thoughts'...

Lonely Rogue.

https://twitter.com/LonelyRogue
angustia
2016-10-16 14:10:12 UTC
The less than code works- CREATE table Product ( product_code huge style(8) CONSTRAINT pk_product_code usual KEY no longer NULL, description varchar2(50) no longer NULL, guide varchar2(50) CONSTRAINT PdfCheckers1 verify ( guide LIKE '%.pdf') ); the following, in case, in case your server/consultation is wanting to Case smooth then this column doesn't settle for till its precisely ".pdf" and all different case like ".Pdf" or ".PDF" could fail. to save faraway from this project both you are able to undertake the fewer than common substitute or use a complicated NLS_SORT and different such key terms. guide varchar2(50) CONSTRAINT PdfCheckers1 verify ( top(guide) LIKE '%.PDF') -- In 'thoughts'... Lonely Rogue.
Stranger~
2012-08-09 04:19:47 UTC
are you doing Info214 lol ? I am not sure about the answer but i found it with one of my friend is



constraint Sale_Current_Date_Check check(Sale_Date<=Sale_Current_Date),





not sure at all :(


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...