主键 primary key的两种分类和创建语法
主键 primary key
MySQL中主键约束分为两种。
单字段主键
多字段主键(复合主键)
单字段主键创建语法:
create table table1 (
id int primary key aito_increment,
name varchar(20),
score float)
多字段字段主键创建语法:
create table table1 (
id int aito_increment,
name varchar(20),
courseid int,
score float,
primary key(id,courseid)
)