Difference between revisions of "SQL Constraints"
From Lianjapedia
Helen.george (Talk | contribs) |
|||
Line 10: | Line 10: | ||
====Table Constraints==== | ====Table Constraints==== | ||
− | {| class="wikitable" | + | {| class="wikitable" width=100% |
|width="33%"|[[CHECK Table Constraint|CHECK]]||width="33%"|[[ERROR Table Constraint|ERROR]]||[[FOREIGN KEY Table Constraint|FOREIGN KEY]] | |width="33%"|[[CHECK Table Constraint|CHECK]]||width="33%"|[[ERROR Table Constraint|ERROR]]||[[FOREIGN KEY Table Constraint|FOREIGN KEY]] | ||
|- | |- | ||
Line 27: | Line 27: | ||
====Column Constraints==== | ====Column Constraints==== | ||
− | {| class="wikitable" | + | {| class="wikitable" width=100% |
|width="33%"|[[AUTO_INCREMENT Column Constraint|AUTO_INCREMENT]]||width="33%"|[[AUTOINC Column Constraint|AUTOINC]]||[[CALCULATED Column Constraint|CALCULATED]] | |width="33%"|[[AUTO_INCREMENT Column Constraint|AUTO_INCREMENT]]||width="33%"|[[AUTOINC Column Constraint|AUTOINC]]||[[CALCULATED Column Constraint|CALCULATED]] | ||
|- | |- |
Revision as of 13:06, 18 January 2013
Purpose
To define rules that help to provide data integrity
See Also
ALTER TABLE, CREATE TABLE, GRANT, REVOKE
Description
A constraint is used to define rules that help to provide data integrity. There are two different types of constraints, TABLE constraints, which do not require any column information and column constraints, which are specific to the column name specified. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation.
Table Constraints
CHECK | ERROR | FOREIGN KEY |
INDEX | KEY | ONAFTERDELETE |
ONAFTERINSERT | ONAFTERUPDATE | ONCLOSE |
ONBEFOREDELETE / ONDELETE | ONBEFOREINSERT / ONINSERT | ONOPEN |
ONROLLBACK | ONBEFOREUPDATE / ONUPDATE | PRIMARY KEY |
UNIQUE |
Column Constraints
AUTO_INCREMENT | AUTOINC | CALCULATED |
CHECK | DEFAULT | DESCRIPTION |
ERROR | FOREIGN KEY | NOCPTRANS |
NOT NULL | NULL | PRIMARY KEY |
RANGE | RECALCULATE | REFERENCES |
SET CHECK | UNIQUE |