CREATE TABLE `micro_student` ( `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '用户id', `name` varchar(10) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '名称', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='学生表';
INSERT INTO `micro_serve`.`micro_student`(`id`, `name`) VALUES (1, '张三'); INSERT INTO `micro_serve`.`micro_student`(`id`, `name`) VALUES (2, '李四'); INSERT INTO `micro_serve`.`micro_student`(`id`, `name`) VALUES (3, '赵五');
CREATE TABLE `micro_student_score` ( `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', `student_id` int unsigned NOT NULL DEFAULT '0' COMMENT '学生id', `subject` varchar(20) NOT NULL DEFAULT '' COMMENT '科目名称', `score` tinyint(4) unsigned COMMENT '分数', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB COMMENT='学生成绩表';
INSERT into `micro_student_score`(`student_id`,`subject`,`score`) VALUES (1,'语文',80),(1,'数学',75),(1,'英语',55); INSERT into `micro_student_score`(`student_id`,`subject`,`score`) VALUES (2,'语文',60),(2,'数学',65),(2,'英语',68); INSERT into `micro_student_score`(`student_id`,`subject`,`score`) VALUES (3,'语文',90),(2,'数学',88),(2,'英语',85);
|