- Primary key constraint is used to uniquely identify each record in database table.
- It won’t allow repetition or duplication of data
- Every table should have a primary key constraint to uniquely identify each row.
- Each table is having only one primary key constraint and it contains only unique values.
- Primary key constraint doesn’t accept null values
Example
Here is the syntax to define EID attribute as a primary key in a Employee table.
CREATE TABLE Employee
(
EID INT PRIMARY KEY IDENTITY NOT NULL,
ENAME VARCHAR(50),
SALARY DECIMAL(10,2),
DEPT VARCHAR(50)
)
Comments
Post a Comment