01 December 2010

SQL constraints concepts

Constraints are used to limit the type of data that can go into a table.

Constraints can be specified when a table is created (with the CREATE TABLE statement) or after the table is created (with the ALTER TABLE statement).

Here are several SQL constraints:

  • NOT NULL
  • UNIQUE
  • PRIMARY KEY
  • FOREIGN KEY - A FOREIGN KEY in one table points to a PRIMARY KEY in another table.
  • CHECK
  • DEFAULT

No comments: