+ 1
what is differnce between unique and primary key?
5 Answers
+ 3
Unique just means that the values of the column have to be all different.
A primary key is unique, can't be null, and you can only have one per table.
+ 3
unique key :- it ensures that no two rows have same value.
primary key :-it accept that only one column can be applied. These doesn't allows null values.
+ 1
Using unique or primary key works better when you have two or more tables and needs reference to the other table
+ 1
Unique ensures that every value of a given column has to be different . A primary key ensures uniqueness as well but unlike Unique constraint, you can only one primary key in a table. Primary key is also different from Unique in that it enforces relationships to other tables of a database.
0
unique key ensures every column has to be different and allow null value.
primary key does same work except it can't have null Value.