Learning immediately: https://edu.csdn.net/course/play/4364/77138?utm_source=blogtoedu
Entity integrity to achieve:
Primary key constraint:
- A table can have only one primary key is set
- Value must be unique
- NOT NULL
- innoDB storage engine, i.e., the primary key index
Specifying a primary key when creating a table:
create table a1
(
sid int primary key,
sname char (10)
)
or
create table a1
(
sid int,
sname char (10)
constraint pk_s_sid primary key(sid)
)
Add a primary key
alter table TStudent add primary key(student)
Drop Primary
alter table TStudent drop primary key
The only constraint value:
- A table can have multiple columns to add unique value constraint
- Only one record is null