Constraints
Constraints are the primary method used to enforce integrity. The types of constraints are PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, and DEFAULT. Defaults can be implemented as constraints or as objects in the database; these are covered in the “Defaults” section of this chapter.
PRIMARY KEY Constraints
To enforce entity integrity—in other words, to uniquely identify each row—you use a PRIMARY KEY constraint. Only one PRIMARY KEY is allowed per table, and it ensures that the column or columns that make up the key are unique and NOT NULL. When a PRIMARY KEY is created, it creates a unique index on the column(s). By default, it creates a CLUSTERED index.
When choosing a candidate for a PRIMARY KEY, try to keep it as short as possible. ...
Get Microsoft® SQL Server™ 2000 Unleashed, Second Edition 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.