What is the SQL PRIMARY KEY Constraint and how it can be used with the database?
The SQL PRIMARY KEY Constraint is required to identify each row in the table uniquely.
Each table should have one and only one primary key.
PRIMARY KEY must have some value and it can not be null.
Each primary key must have unique value.
SQL PRIMARY KEY Constraint Example:
Lets assume that you have a table 'order'. Each order must have order number. Order number must be unique for each order. It can not be null. So, Order Number can be defined as a primary key.
Use following syntax of sql primary key constraint at the time of creating table:
CREATE TABLE order(
order_number INT NOT NULL,
name VARCHAR(50) NOT NULL,