Enforcing Integrity with Constraints

Constraints are an ANSI-standard method used to enforce the integrity of the data in the database. They are rules that SQL Server Database Engine enforces for you. There are various types of constraints, each of which enforces a specific rule. All of the built-in constraints are enforced before a data change is made to the database so that if a constraint is violated, the modification statement is not executed. This way, there is no rollback of data necessary if the constraint is violated.

SQL Server 2005 provides the following types of constraints:

  • PRIMARY KEY constraints

  • UNIQUE constraints

  • FOREIGN KEY constraints

  • CHECK constraints

  • DEFAULT definitions

  • NULL/NOT NULL constraints

The following sections will describe ...

Get Microsoft® SQL Server™ 2005 Administrator's Companion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.