Difference between revisions of "SQL Constraints"

From Lianjapedia
Jump to: navigation, search
Line 34: Line 34:
 
|[[DESCRIPTION Column Constraint|DESCRIPTION]]||[[ERROR Column Constraint|ERROR]]||[[FOREIGN KEY Column Constraint|FOREIGN KEY]]
 
|[[DESCRIPTION Column Constraint|DESCRIPTION]]||[[ERROR Column Constraint|ERROR]]||[[FOREIGN KEY Column Constraint|FOREIGN KEY]]
 
|-
 
|-
|[[NOCPTRANS Column Constraint|NOCPTRANS]]||[[NOT NULL Column Constraint|NOT NULL]]||[[NULL Column Constraint|NULL]]
+
|[[HELP Column Constraint|HELP]]||[[NOCPTRANS Column Constraint|NOCPTRANS]]||[[NOT NULL Column Constraint|NOT NULL]]
 
|-
 
|-
|[[PRIMARY KEY Column Constraint|PRIMARY KEY]]||[[RANGE Column Constraint|RANGE]]||[[RECALCULATE Column Constraint|RECALCULATE]]
+
|[[NULL Column Constraint|NULL]]||[[PRIMARY KEY Column Constraint|PRIMARY KEY]]||[[RANGE Column Constraint|RANGE]]
 
|-
 
|-
|[[REFERENCES Column Constraint|REFERENCES]]||[[SET CHECK Column Constraint|SET CHECK]]||[[UNIQUE Column Constraint|UNIQUE]]
+
|[[RECALCULATE Column Constraint|RECALCULATE]]||[[REFERENCES Column Constraint|REFERENCES]]||[[SET CHECK Column Constraint|SET CHECK]]
 +
|-
 +
|[[UNIQUE Column Constraint|UNIQUE]]||||
 
|-
 
|-
 
|}
 
|}

Revision as of 11:14, 14 July 2014

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 CHOICES DEFAULT
DESCRIPTION ERROR FOREIGN KEY
HELP NOCPTRANS NOT NULL
NULL PRIMARY KEY RANGE
RECALCULATE REFERENCES SET CHECK
UNIQUE