SQL CONSTRAINTS

The SQL constraints are the rules enforced on the data in a table. A constraint can be specified with the CREATE TABLE statement at the time table creation or we can specify it with the ALTER TABLE statement after the table creation.

Syntax:

CREATE TABLE <em>tableName</em>
(
<em>columnName1 datatype</em>(<em>size</em>) <em>constraintName</em>,
<em>columnName2 data_type</em>(<em>size</em>) <em>constraintName</em>,
<em>columnName2 data_type</em>(<em>size</em>) <em>constraintName</em>,
....
);

Commonly used constraints in SQL:

5. SQL CHECK Constraint
6. SQL DEFAULT Constraint

No comments: