mysql建表语句

drop table if exists score;
drop table if exists grade;
drop table if exists class;
drop table if exists student;

create table grade
(
    id bigint not null primary key auto_increment,
    grade_no varchar(16) default null
) engine = InnoDB default charset = utf8;

create table class
(
    id bigint not null primary key auto_increment,
    class_no varchar(16) default null comment '班级号'
) engine = InnoDB default charset = utf8;

create table student
(
    student_id         bigint not null primary key auto_increment,
    student_name varchar(100) null ,
    id_card varchar(32) null,
    sex varchar(2) null,
    grade_id bigint not null comment '年级id',
    class_id bigint not null comment '班级id',
    createtime timestamp                    null,
    modifytime timestamp                    null,
    version varchar(1) default 1 not null comment '版本号',
    constraint fk_student_class foreign key (class_id) references class (id),
    constraint fk_student_grade foreign key (grade_id) references grade (id)
) ENGINE = InnoDB default charset = utf8;


create table score
(
    exam_id          bigint not null primary key auto_increment,
    exam_information varchar(100) null ,
    student_id       bigint not null,
    student_name varchar(32) null,
    chinese_score int null comment '语文成绩',
    math_score int null comment '数学成绩',
    english_score int null comment '英语成绩',
    composite_score int null comment '综合成绩',
    total int null comment '总成绩',
    createtime timestamp                    null,
    modifytime timestamp                    null,
    version varchar(1) default 1 not null comment '版本号',
    constraint fk_score_student foreign key (student_id) references student (student_id)
) ENGINE = InnoDB default charset = utf8;


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值