General information
Forum:
Microsoft SQL Server
A table usually has a column or combination of columns whose values uniquely identify each row in the table. This column (or columns) is called the primary key of the table and enforces the entity integrity of the table. A table can have only one PRIMARY KEY constraint, and no column that participates in the PRIMARY KEY constraint can accept null values.
You can use UNIQUE constraints to ensure that no duplicate values are entered in specific columns that do not participate in a primary key. While both a UNIQUE constraint and a primary key enforce uniqueness, use a UNIQUE constraint instead of a PRIMARY KEY constraint when you want to enforce the uniqueness of:
A column, or combination of columns, that is not the primary key.
Multiple UNIQUE constraints can be defined on a table, whereas only one PRIMARY KEY constraint can be defined on a table.
A column that allows null values.
UNIQUE constraints can be defined on columns that allow null values, whereas PRIMARY KEY constraints can be defined only on columns that do not allow null values.
A UNIQUE constraint can also be referenced by a FOREIGN KEY constraint.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only