Monday, 20 December 2010

What is a "constraint"?

- A constraint allows you to apply simple referential integrity checks to a table. There are four primary types of constraints that are currently supported by SQL Server:

PRIMARY/UNIQUE - enforces uniqueness of a particular table column.

DEFAULT - specifies a default value for a column in case an insert operation does not provide one.

 FOREIGN KEY - validates that every value in a column exists in a column of another table.

 CHECK - checks that every value stored in a column is in some specified list.

 Each type of constraint performs a specific type of action. Default is not a constraint. NOT NULL is one more constraint which does not allow values in the specific column to be null. And also it the only constraint which is not a table level constraint.

No comments:

Post a Comment