what is a primary key in a table?
Answers
Answered by
7
A primary key is a special relational database table column (or combination of columns) designated to uniquely identify all table records.
A primary key’s main features are:
1) It must contain a unique value for each row of data.
2) It cannot contain null values.
A primary key is either an existing table column or a column that is specifically generated by the database according to a defined sequence.
A primary key’s main features are:
1) It must contain a unique value for each row of data.
2) It cannot contain null values.
A primary key is either an existing table column or a column that is specifically generated by the database according to a defined sequence.
Pickeyleo:
thank you
Answered by
2
Short notes on primary Key:
(i) It is used to uniquely identify rows in a table.
(ii) There can be only primary key in a table.
(iii) It may consist of more than one column,if so, it is called as composite primary key. A composite primary key can not have more than 32 columns.
(iv) It wont allow you to use duplicate values.
(v) It automatically creates unique index to enforce uniqueness.
(vi) The size of primary key can not be exceed approximately one database block.
(vii) It can not be implemented on columns having Log,Long,Long raw etc.
Example of primary key:
Create table emp(eno number primary key, ename varchar2(10));
insert into emp values(1,'A');
insert into emp values(2,'B');
Error: Unique constraint violated.
Hope it helps!
Similar questions