建表、数据插入代码:

#新建学生表
drop table if exists student;
create table student(
    sno varchar(20) not null primary key comment '学号',
    sname varchar(20) not null comment '学生姓名',
    ssex varchar(20) not null comment '学生性别',
    sbirthday Datetime comment '学生出生年月',
    class varchar(20) comment '学生所在班级'
);
#给学生表中插入数据
insert into student values(
    '108','曾华','','1977-09-01','95033'),(
    '105','匡明','','1975-10-02','95031'),(
    '107','王丽','','1976-01-23','95033'),(
    '101','李军','','1976-02-20','95033'),(
    '109','王芳','','1975-02-10','95031'),(
    '103','陆君','','1974-06-03','95031');
#新建课程表
drop table if exists course;
create table course(
    cno varchar (20) not null primary key comment '课程号',
    cname varchar (20) not null comment '课程名称',
    tno varchar (20) not null comment '教工编号'
);
#给课程表中插入数据
insert into course values
('3-105','计算机导','825'),
('3-245','操作系统','804'),
('6-166','数字电路','856'),
('9-888','高等数学','831');
#新建成绩表
drop table if exists score;
create table score(
    sno varchar (20) not null comment '学号',
    cno varchar (20) not null comment '课程号',
    degree Decimal(4,1) comment '成绩',
    primary key(sno,cno)
);
#给成绩表中插入数据
insert into score values
('103','3-245',86),
('105','3-245',75),
('109','3-245',68),
('103','3-105',92),
('105','3-105',88),
('109','3-105',76),
('101','3-105',64),
('107','3-105',91),
('108','3-105',78),
('101','6-166',85),
('107','6-166',79),
('108','6-166',81);
#新建教师表
drop table if exists teacher;
create table teacher(
    tno varchar (20) not null primary key comment '教工编号',
    tname varchar (20) not null comment '教工姓名',
    tsex varchar (20) not null comment '教工性别',
    tbirthday datetime comment '教工出生年月',
    prof varchar (20) comment '职称',
    depart varchar (20) not null comment '教工所在部门'
);
#给教师表中插入数据
insert into teacher values
('804','李诚','','1958-12-02','副教授','计算机'),
('856','张旭','','1969-03-12','讲师','电子工程'),
('825','王萍','','1972-05-05','助教','计算机系'),
('831','刘冰','','1977-08-14','助教','电子工程');
建表、数据插入代码

相关文章:

  • 2022-12-23
  • 2022-03-03
  • 2021-12-08
  • 2021-10-27
  • 2021-08-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-11-28
  • 2021-12-01
  • 2021-11-20
相关资源
相似解决方案