You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
hutao/docs/MySQL/mysql是怎样使用的数据初始化7.0.sql

48 lines
2.0 KiB

USE hutao;
CREATE TABLE IF NOT EXISTS
student_info
(
number INT PRIMARY KEY COMMENT '学生ID信息表的主键',
name VARCHAR(5) NOT NULL COMMENT '学生姓名',
sex ENUM('', '') COMMENT '学生性别',
id_number CHAR(18) COMMENT '身份证',
department VARCHAR(30) COMMENT '学院',
major VARCHAR(30) COMMENT '专业',
enrollment_time DATE COMMENT '入学时间',
UNIQUE KEY id_number (id_number)
) COMMENT '学生信息表';
CREATE TABLE IF NOT EXISTS
student_score
(
number INT COMMENT '学生ID',
subject VARCHAR(30) COMMENT '学科',
score INT NOT NULL COMMENT '成绩',
PRIMARY KEY (number, subject),
CONSTRAINT FOREIGN KEY (number) REFERENCES student_info(number)
) COMMENT '学生成绩表';
SHOW CREATE TABLE student_info;
INSERT INTO
student_info(number, name, sex, id_number, department, major, enrollment_time)
VALUES
(20210101, '狗哥', '', '158177200301044792', '计算机学院', '计算机科学与工程', '2021-09-01'),
(20210102, '猫爷', '', '151008200201178529', '计算机学院', '计算机科学与工程', '2021-09-01'),
(20210103, '艾希', '', '17156320010116959X', '计算机学院', '软件工程', '2021-09-01'),
(20210104, '亚索', '', '141992200201078600', '计算机学院', '计算机科学与工程', '2021-09-01'),
(20210105, '莫甘娜', '', '181048200008156368', '航天学院', '飞行器设计', '2021-09-01'),
(20210106, '赵信', '', '197995200201078445', '航天学院', '电子信息', '2021-09-01');
INSERT INTO
student_score(number, subject, score)
VALUES
(20210101, '计算机是怎样运行的', 78),
(20210101, 'MySQL是怎样运行的', 88),
(20210102, '计算机是怎样运行的', 100),
(20210102, 'MySQL是怎样运行的', 98),
(20210103, '计算机是怎样运行的', 59),
(20210103, 'MySQL是怎样运行的', 61),
(20210104, '计算机是怎样运行的', 55),
(20210104, 'MySQL是怎样运行的', 46);