Difference between revisions of "SQL Constraints"
From Lianjapedia
Line 11: | Line 11: | ||
{| class="wikitable" | {| class="wikitable" | ||
− | |[[CHECK Table Constraint|CHECK]]||[[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]] |
|- | |- | ||
|[[INDEX Table Constraint|INDEX]]||[[KEY Table Constraint|KEY]]||[[ONAFTERDELETE Table Constraint|ONAFTERDELETE]] | |[[INDEX Table Constraint|INDEX]]||[[KEY Table Constraint|KEY]]||[[ONAFTERDELETE Table Constraint|ONAFTERDELETE]] | ||
Line 28: | Line 28: | ||
{| class="wikitable" | {| class="wikitable" | ||
− | |[[AUTO_INCREMENT Column Constraint|AUTO_INCREMENT]]||[[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]] |
|- | |- | ||
|[[CHECK Column Constraint|CHECK]]||[[DEFAULT Column Constraint|DEFAULT]]||[[DESCRIPTION Column Constraint|DESCRIPTION]] | |[[CHECK Column Constraint|CHECK]]||[[DEFAULT Column Constraint|DEFAULT]]||[[DESCRIPTION Column Constraint|DESCRIPTION]] |
Revision as of 07:39, 21 November 2012
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 |