Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Difference between PK and UK

Author  Topic 

ballabhoks
Starting Member

18 Posts

Posted - 2004-03-08 : 06:47:03
What are the major differences between Primary Key and Unique Key

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2004-03-08 : 06:51:40
A Primary Key Constraint implies that NO value can be NULL, while with a Unique Constraint one value can be NULL. You can only have one PK in a table, but you can have multiple Unique constraints.

--Frank
http://www.insidesql.de
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-03-08 : 08:31:05
Also a PK is held as a constraint on the table with a unique index to support it.
A unique key could just be an index with no corresponding table constraint.

More importantly a PK is meant to be a row identifier whereas a unique index just constrains the values. i.e. changing a PK field makes it a different row and so should be implemented as a delete and insert.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -