Advertisement

Latest Post

Saturday, 24 September 2016

What is PRIMARY KEY

PRIMARY KEY

Primary key is cloumn in a table that uniquely identify the earch rows.
A table has only one primary key and primary can not be hold the null value. 


Following is the example to apply PRIMARY KEY Constraint on CREATE TABLE

CREATE TABLE Employee
(
Id INT NOT NULL,
Name varchar(255) NOT NULL,
Address varchar(255),
Age INT,
CONSTRAINT pk_EmployeeID PRIMARY KEY (Id)
)

Following is the example to apply PRIMARY KEY Constraint on ALTER TABLE

ALTER TABLE Employee
ADD PRIMARY KEY (Id)

Following is the example to DROP a PRIMARY KEY Constraint

ALTER TABLE Employee

DROP CONSTRAINT pk_EmployeeID

More SQL Constraints

Government Jobs