Primary key
|
Unique Key
|
1- Primary
key doesn’t have null value.
2- A
table can have only one primary key.
3- By
default primary key have clustered index.
|
Unique key can hold null value but only once.
A table can have more than on unique key.
By default Unique key have non- clustered index.
|
Constraints - Constraints are the rules enforced on data columns on table. This ensures the accuracy and reliability of the data in the database. Constraints define some conditions that restricts the column to remain true while inserting or updating or deleting data in column. Constraints can be defined in two ways 1) The constraints can be specified immediately after the column definition. This is called column-level definition. 2) The constraints can be specified after all the columns are defined. This is called table-level definition. Types of Constraints in SQL-Server NOT NULL - This constraint is responsible for a column to confirm that a column cannot have a null value. DEFAULT – This constraint provides a default value when specified non for this column. UNIQUE - This constraint insure that each row for the column has different value. PRIMARY KEY - Primary key constraint is a combination of a NOT NULL constraint and a UNIQUE constra
Comments
Post a Comment