DIFFERENCE BETWEEN PRIMARY KEY AND UNIQUE KEY – SQL SERVER 2005

1. PRIMARY key does not allow null values in the entire column.You
can insert one null value in the entire unique key column;means it
allows one null value per column.

2. PRIMARY key by default creates a clustured index on the table.In
case of unique key you have to explicitly create an unique non
clustured index.

3. You can set primary key from the object explorer.( Right click on
the column name and say primary key ). There is not such facility
available in case of unique keys.

4. In case of unique key , you have to add a constraint to create a
non clustured index. In case of primary key , SQL Server will take care
of this.

Pawan Kumar

Pawankkmr@hotmail.com

Advertisements