What is the difference between Primary Key and unique key constraint?

前端 未结 5 1256
我寻月下人不归
我寻月下人不归 2020-12-16 12:05

What is the difference between Primary key And unique Key constraint?

What\'s the use of it??

5条回答
  •  难免孤独
    2020-12-16 12:10

    Short version:

    • From the point of view of database theory, there is none. Both are simply candidate keys.
    • In practice, most DMBS like to have one "standard key", which can be used for e.g. deciding how to store data, and to tell tools and DB clients which is the best way to identify a record.

    So distinguishing one unique key as the "primary key" is just an implementation convenience (but an important one).

提交回复
热议问题