Difference between revisions of "SQL Constraints"

From Lianjapedia
Jump to: navigation, search
Line 13: Line 13:
 
|[[CHECK Table Constraint|CHECK]]||[[ERROR Table Constraint|ERROR]]||[[FOREIGN KEY Table Constraint|FOREIGN KEY]]
 
|[[CHECK Table Constraint|CHECK]]||[[ERROR Table Constraint|ERROR]]||[[FOREIGN KEY Table Constraint|FOREIGN KEY]]
 
|-
 
|-
|[[INDEX Table Constraint|INDEX]]||[[KEY Table Constraint|KEY]]||[[ONCLOSE Table Constraint|ONCLOSE]]
+
|[[INDEX Table Constraint|INDEX]]||[[KEY Table Constraint|KEY]]||[[ONAFTERDELETE Table Constraint|ONAFTERDELETE]]
 +
|-
 +
|[[ONAFTERINSERT Table Constraint|ONAFTERINSERT]]||[[ONAFTERUPDATE Table Constraint|ONAFTERUPDATE]]||[[ONCLOSE Table Constraint|ONCLOSE]]
 
|-
 
|-
 
|[[ONDELETE Table Constraint|ONDELETE]]||[[ONINSERT Table Constraint|ONINSERT]]||[[ONOPEN Table Constraint|ONOPEN]]
 
|[[ONDELETE Table Constraint|ONDELETE]]||[[ONINSERT Table Constraint|ONINSERT]]||[[ONOPEN Table Constraint|ONOPEN]]

Revision as of 07:07, 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
ONDELETE ONINSERT ONOPEN
ONROLLBACK 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