What is the difference b/w unique and primary key? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the difference b/w unique and primary key?

10th Apr 2017, 4:54 PM
T Karthikeyan
T Karthikeyan - avatar
2 Answers
+ 27
For Starters:- Unique key can have a null value in the column and you can have multiple column's having unique key assigned to them. Primary key can only be one in the table and cannot contain null values.
10th Apr 2017, 5:09 PM
Frost
Frost - avatar
+ 6
1. Primary key is made up of a column or set of columns that identifies a record uniquely in the table. Unique key ensures non duplicate value in the column across records. 2 Primary key or any of its part can't be left empty. But Unique column can have null value unless it told not to allow nulls. 3. There can only be one primary key per table. But a table can have multiple unique keys.
10th Apr 2017, 5:15 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar