SQL Constraint Primary Key
In this video, we will see primary key constraint with example.
Link of Unique Constraint: • SQL Constraint Unique
PRIMARY KEY –
Uniquely identifies each row in a table
Key points:
Only one primary key per table.
PK does not allow null value.
PK does not allow duplicate values.
PK = NOT NULL+ UNIQUE.
Syntax:
CREATE TABLE tbl_name (
col1 data_type PRIMARY KEY,
... );
OR
CREATE TABLE tbl_name (
col1 data_type not null,
col2 data_type not null, ... ,
CONSTRAINT cons_name PRIMARY KEY (col1, col2) );
OR
ALTER TABLE tbl_name
ADD PRIMARY KEY (col_name)
Connect me to insta ID for any queries
thisisanandyadav