Wednesday, November 24, 2010

[T-SQL] Table Constraints

Table constraints define rules regarding the values allowed in columns and are the standard mechanism for enforcing data integrity.

Types of Constraints:
  1. NOT NULL enforces not to accept NULL values
  2. UNIQUE assures that the data is unique in the column (including one NULL).
  3. PRIMARY KEY uniquely identifies each record in the table without allowing NULL.
  4. FOREIGN KEY constraints the data to be inserted that is available in table's column it points to.
  5. CHECK is used to limit the value range that can be placed in that column.
  6. DEFAULT is used to insert a default value to all new records, if no value is specified.

No comments:

Post a Comment