SQL PRIMARY Key
SQL – PRIMARY Key Constraint :
1 . At The Time Of Table Creation :
SQL PRIMARY Key : PRIMARY Key Constraint is used to identify every record uniquely which can’t be null. There can be only one primary key in a table.
SQL – PRIMARY Key Constraint Syntax Example :
ID int(11) NOT NULL,
Name varchar(110) NOT NULL,
Email varchar(100) NOT NULL,
CONSTRAINT USER_ID_PRIMARY_KEY PRIMARY KEY (ID)
Where USER_EMAIL is Constraint’s name you can choose constraint name as per you understanding.
2 .In Existing Table :
CONSTRAINT USER_ID_PRIMARY_KEY PRIMARY KEY (ID);
Drop PRIMARY Key Constraint :
DROP CONSTRAINT USER_ID_PRIMARY_KEY;
Note : In Mysql You have to Use Following Query to Drop the Constraint :
DROP INDEX USER_ID_PRIMARY_KEY;