The difference is as follows: 1) Basically we define a column/multiple column's as primary key that represents the whole row, A unique key can be any. 2) Primary key are considered as Clustered Index for the table and as we can define only one clustered index for the table, the other columns can only be non-clustered index. 3) We can use primary key in where clause for updating a record as it represents that row which may not be true in case of unique key. Even if the key is unique the table might have a composite key as a primary key. 4) A primary key can act as a foreign key for other related tables, a unique key cannot. 5) The data in a row is dependent on a primary key whereas it may not be for the unique key.
This is all that i know about it. Others can also add some more things to it.
Above answer was rated as good by the following members: Mohamed Harish
RE: What is the basic difference between primary key a...
Hi
Basic Diffrence between primary key and unique key is the capability of unique key
for storing null values a primary key on a column gurantees that the column must contain a value for a given row but a unique key only guarantees that a column should be unique.
Apart from this difference in oracle unique and primary key creates difference in
performance
e.g : a primary key on a table enhance capability of using index
on select count(*) from table_name only if the table is analyzed
If we define a unique key as not null then it also take a unique value as well as not null value that means one can not insert Null value in that column.
RE: What is the basic difference between primary key and (unique key along with Not NULL).
The difference is as follows: 1) Basically we define a column/multiple column's as primary key that represents the whole row A unique key can be any. 2) Primary key are considered as Clustered Index for the table and as we can define only one clustered index for the table the other columns can only be non-clustered index. 3) We can use primary key in where clause for updating a record as it represents that row which may not be true in case of unique key. Even if the key is unique the table might have a composite key as a primary key. 4) A primary key can act as a foreign key for other related tables a unique key cannot. 5) The data in a row is dependent on a primary key whereas it may not be for the unique key.
This is all that i know about it. Others can also add some more things to it.
RE: What is the basic difference between primary key and (unique key along with Not NULL).
hi every one
differences
1) primary key is defined only on one column where as unique + not null can be defined on many columns
2) we can define the relationship ( master detail relationship) with references to unique+not null column but it is not possible to remove the relationship with
alter table <tablename> primary key cascade. Because Unique + Not null is not exactly primary key
3) When you refer the data dictionery with unique and not null it is going to create to different constraints where as with primary key it is going to create one constraint.
RE: What is the basic difference between primary key and (unique key along with Not NULL).
In addition to all this unique key along with Not NULL constraint has got a name i.e. candidate key .So a table having a column which is unique as well as not null apart from primar key is known as a candidate key.Thanks...