Difference between primary key and unique key in sql.
======================================================
======================================================
Primary key Unique key
1-can not be null 1-can be null and multiple null
2-can not be same value 2-can not be same value
3-only be one column name 3-multiple column could be unique
1-can not be null 1-can be null and multiple null
2-can not be same value 2-can not be same value
3-only be one column name 3-multiple column could be unique
suppose emp_id is primary key and city is the unique key
primary key unique key
------------------------------ ------------------------------ -----------------------
emp_id emp_nm sal city
------------------------------ ------------------------------ -----------------------
0 AA 18000 (null)
1 BB 18000 NEW DELHI
3 CC 18000 NOIDA
2 DD 18000 (null)
4 EE 18000 KANPUR
5 FF 18000 (null)
6 GG 18000 (null)
------------------------------ ------------------------------ ----------------------
primary key
------------------------------
emp_id emp_nm sal city
------------------------------
0 AA 18000 (null)
1 BB 18000 NEW DELHI
3 CC 18000 NOIDA
2 DD 18000 (null)
4 EE 18000 KANPUR
5 FF 18000 (null)
6 GG 18000 (null)
------------------------------
0 comments:
Post a Comment