-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPRIMARY KEY in SQL.txt
More file actions
16 lines (15 loc) · 886 Bytes
/
PRIMARY KEY in SQL.txt
File metadata and controls
16 lines (15 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// PRIMARY Key
-> The PRIMARY KEY constraint uniquely identifies each record in a database table.
Primaray keys must contains UNIQUE values. A primary key column cannot contain NULL values.
Most tables should have a primary key, and each table can have only ONE primary key.
syntax: CREATE TABLE example(s_id int (10) NOT NULL PRIMARY KEY ,name varchar
(50), roll_no int (10) ,number int (10));
ex: desc example;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| s_id | int | NO | PRI | NULL | |
| name | varchar(50) | YES | | NULL | |
| roll_no | int | YES | | NULL | |
| number | int | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+