SQL Constraints: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=Internal= * SQL =Overview= =Primary Key Constraint= <syntaxhighlight lang='sql'> CREATE TABLE ... ( ... CONSTRAINT pk_someconstraint PRIMARY KEY (somecolumn) ); </syntaxhighlight>") |
|||
Line 11: | Line 11: | ||
( ... | ( ... | ||
CONSTRAINT pk_someconstraint PRIMARY KEY (somecolumn) | CONSTRAINT pk_someconstraint PRIMARY KEY (somecolumn) | ||
); | |||
</syntaxhighlight> | |||
=Check Constraint= | |||
<syntaxhighlight lang='sql'> | |||
CREATE TABLE ... | |||
( ... | |||
eye_color CHAR(2) CHECK (eye_color IN ('BR', 'BL', 'GR')), | |||
... | |||
); | ); | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 23:53, 22 May 2024
Internal
Overview
Primary Key Constraint
CREATE TABLE ...
( ...
CONSTRAINT pk_someconstraint PRIMARY KEY (somecolumn)
);
Check Constraint
CREATE TABLE ...
( ...
eye_color CHAR(2) CHECK (eye_color IN ('BR', 'BL', 'GR')),
...
);