In this tutorial, we will learn how to use PRIMARY KEY
using SQL.
PRIMARY KEY
Constraint ensures that only unique record is inserted in a table.PRIMARY KEY
is used to uniquely identify each row in a table.PRIMARY KEY
cannot contain NULL
values, it must contains unique values.PRIMARY KEY
, which may consist of single or multiple fields.To add a PRIMARY KEY
constraint when a table is created, a statement is as follow:
To define a PRIMARY KEY
constraint on multiple columns, a statement is as follow:
To add a PRIMARY KEY
constraint after creating a table, a statement is as follow:
To add a PRIMARY KEY
constraint after creating a table on multiple columns, a statement is as follow:
To drop a PRIMARY KEY
Constraint, the statement is as follow: