+ 1

What is the difference between unique and primary key?

In SQL

8th Feb 2018, 3:43 AM
Shivam Jaiswal
Shivam Jaiswal - avatar
4 Réponses
+ 15
in unique constraint , u can have null values ... but in primary u can't have null values //duplicate values is not allowed in both https://stackoverflow.com/questions/9565996/difference-between-primary-key-and-unique-key
8th Feb 2018, 4:22 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 11
An unique constraint on an attribute would allow null values (albeit only one). An attribute which is designated as primary key is both unique and not null.
8th Feb 2018, 4:01 AM
Hatsy Rei
Hatsy Rei - avatar
8th Feb 2018, 4:10 AM
~Sudo Bash
~Sudo Bash - avatar
0
thank you for the ans
8th Feb 2018, 6:54 PM
Shivam Jaiswal
Shivam Jaiswal - avatar