Mysql programs for BE IT students Bangalore
SQL PRIMARY KEY Constraint
The PRIMARY KEY is used to uniquely identifies each record in a table.
Primary keys must contain the unique values in a table.
A primary key contains column cannot contains the NULL values.
Each table should have a primary key column.
Each table can have only ONE primary key column.
MySQL:
Syntax:
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
City varchar(255),
PRIMARY KEY (P_Id)
)
SQL Server / Oracle / MS Access:
CREATE TABLE Persons
(
P_Id int NOT NULL PRIMARY KEY,
LastName varchar(255) NOT NULL,
)
|