The primary key is used to uniquely
identify each record in the table. Primary key contain unique value .The
primary key cannot contain NULL value, each table contain only one primary key.
Primary key on create table –
Create table employee
Id int NOT NULL,
First name varchar(250) NOT NULL,
Last name varchar(250),
City varchar(250),
Salary int,
CONSTRAINT emp_id PRIMARY KEY (ID,
First Name)
Primary key on alter table-
ALTER table employee
Add primary key(Id)
Drop a Primary Key –
ALTER table employee
Drop CONSTRAINT emp_id
Author - Sachin Pathak
No comments:
Post a Comment