SQL Primary key with Example

aimtocode

Primary Key

Primary key is a candidate key of the table selected to identify each record uniquely in table. Primary key does not allow null value in the column and keeps unique values throughout the column

Primary key can be defined as a set of one or more fields/columns of a table that uniquely identify a record in a database table. A record can be uniquely identified when the column which includes unique value like Employee_Id of an employee from an organization. It will not accept null values and duplicate values. Only one primary key can exist in a single table not more than one.

Example: Suppose a table consists of Employee data with fields Employee_Name, Employee_Address, Employee_Id and Employee_Designation so in this table only one field is there which is used to uniquely identify detail of Employee that is Employee_Id.



Read Also:


aimtocode