题目参照:
https://www.cnblogs.com/lsgcoder101/p/6011059.html
登录数据库
mysql -uroot -p
创建和选择数据库
create database dbo;
use dbo;
创建数据表
create table stuscore
(
name char(50) NULL,
subject char(50) NULL ,
score int NULL,
stuid int NULL,
record_id int not null auto_increment, # 主键不能为null(否则此语句出错)
PRIMARY KEY (record_id)
) engine=InnoDB; #存储引擎是InnoDB
#插入数据
insert into dbo.stuscore values ('张三','数学',89,1,null); # 自增主键可以给null
insert into dbo.stuscore values ('张三','语文',80,1,null);
insert into dbo.stuscore values ('张三','英语',70,1, null);
insert into dbo.stuscore values ('李四','数学',90,2,null);
insert into dbo.stuscore values ('李四','语文',70,2,null);
insert into dbo.stuscore values ('李四','英语',80,2,null);
<