+ 3
What is the difference between unique and primary key?
11 Antworten
+ 10
let's start with a fact alright , primary key is unique and not null but every unique key and not null key cannot be a primary key...
for example in a company's database ,employee ID can be kept as a primary key but his Mobile number is usually kept as a unique key and not primary key.
Because no two employees can have same mobile number therefore they should be unique and not null but since employee ID is more suitable to keep as primary key, we do It That Way... I hope this gives you answer.
And bonus one, you can only have one primary key in a table but you can have multiple unique keys in a table...
+ 3
You can only have one primary key per table, and it is a unique key not accepting null values.
@Sanoj: You may have several null values in a unique column.
+ 1
primary key is one of the unique column of table that can't have null value and it can index every row in a table
+ 1
and unique is a constraint that you can use in others columns to force the data be unique
+ 1
all primary keys are unique but not all unique are primary keys.
+ 1
u can only use one primary key in a table while u can use multiple unique key in a table.. :)
+ 1
primary key unique and not null (no redundancies no null values) and have vital role in the tables relationship ....
unique (no redundancies)
+ 1
Primary Key is like your driver's license number: it is unique, and it won't ever change or be used for anybody else.
So, if you are to choose between using one's ID number and one's cell phone number as primary key, you should choose using the ID number, as it is possible that you change your cell phone number but your ID number is Unique and it won't ever change.
0
primary key can't have null value while unique can have only one null value so that the column can be uniquely defined.
0
primary key does not null values and duplicate values but where unique key means not allow duplicates value...
0
primary key has clusters index on it and it can be Va foreign key for other table. Not null can't.