• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the difference between primary key & unique key in Sql?

 
BalaMurali dhar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between primary key & unique key in Sql?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15644
48
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unique key
Wikipedia wrote:A table can have at most one primary key, but more than one unique key. A primary key is a combination of columns which uniquely specify a row. It is a special case of unique keys. One difference is that primary keys have an implicit NOT NULL constraint while unique keys do not. Thus, the values in unique key columns may or may not be NULL, and in fact such a column may contain at most one NULL fields.[7] Another difference is that primary keys must be defined using another syntax.

(Please try searching yourself).
 
BalaMurali dhar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question was asked in the interview. Thank very much. Your comment is highly appreciated
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic