create table documents ( id integer not null primary key , title varchar(99) not null , added date not null , constraint only_new_ones check ( added >= '2007-01-01' ) );
The CHECK constraint should always be given a descriptive name, because this helps identify the source of the error when the constraint is violated. The constraint name is optional, but the difference is between getting an error message that looks like this:
INSERT statement terminated. CHECK constraint "CK__documents__added__73852659" was violated.
and one that looks like this:
INSERT statement terminated. CHECK constraint "only_new_ones" was violated.
Use a constraint name that describes the constraint accurately.
Dig Deeper on Oracle development languages
Related Q&A from Rudy Limeback
Read an example of an SQL case expression from our SQL expert Rudy Limeback. Continue Reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clause Continue Reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.