1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| create table student ( id bigint auto_increment, stu_name varchar(32) null comment '学生姓名', total_score decimal(5,2) default 0 null comment '总分', constraint student_pk primary key (id) ) comment '学生表';
create table course_score ( stu_id bigint null comment '学生id', course_id bigint null comment '课程id', score decimal(5,2) default 0.00 null comment '课程分数' ) comment '选修课程成绩表';
insert into student(id, stu_name, total_score) value (1, '刘德华', 0); insert into student(id, stu_name, total_score) value (2, '张学友', 0); insert into student(id, stu_name, total_score) value (3, '郭富城', 0);
insert into course_score(stu_id, course_id, score) VALUE (1, 1, 80); insert into course_score(stu_id, course_id, score) VALUE (1, 2, 80); insert into course_score(stu_id, course_id, score) VALUE (1, 3, 80); insert into course_score(stu_id, course_id, score) VALUE (2, 2, 95); insert into course_score(stu_id, course_id, score) VALUE (2, 3, 85); insert into course_score(stu_id, course_id, score) VALUE (3, 1, 100); insert into course_score(stu_id, course_id, score) VALUE (3, 2, 75);
|