nThe PRIMARY KEY constraint uniquely identifies each record in a database table.
nPrimary keys must contain unique values.
nA primary key column cannot contain NULL values.
nEach table should have a primary key, and each table can have only ONE primary key.
Create-primary key
CREATE TABLE EMPtbl1( (EMPID int NOT NULL, EMPname varchar(255) NOT NULL,
company varchar(255),salary varchar(255),City varchar(255),CONSTRAINT pk_EMPtbl1 PRIMARY KEY (EMPID, salary))
company varchar(255),salary varchar(255),City varchar(255),CONSTRAINT pk_EMPtbl1 PRIMARY KEY (EMPID, salary))
Alter-primary key
ALTER TABLE EMPtbl1
ADD CONSTRAINT pk_EMPtbl1 PRIMARY KEY (EMPID, salary)
Drop-primary key
ALTER TABLE EMPtbl1
DROP CONSTRAINT pk_EMPtbl1
No comments:
Post a Comment