#(1)创建数据库stuexpm
show databases;
create database stuexpm;
#(2)创建studentinfo表,显示studentinfo表的基本结构
#表4.9
use stuexpm;
create table StudentInfo
(
StudentID varchar(6) not null primary key comment '学号',
Name varchar(8) not null comment '姓名',
Sex varchar(2) not null default '男' comment '性别',
Birthday date not null comment '出生日期',
Speciality varchar(12) null comment '专业',
Address varchar(50) null comment '家庭地址'
)comment '学生表';
create table CourseInfo
(
CourseID varchar(4) not null primary key comment '课程号',
CourseName varchar(16) not null comment '课程名',
Credit tinyint null comment'学分'
)comment '课程表';
show columns from StudentInfo;
use stuexpm;
insert into studentinfo
values
('181001','成志强','男','1998-08-17','计算机','北京市海淀区'),
('181002','孙红梅','女','1997-11-23','计算机','成都市锦江区'),
('181003','朱丽','女','1998-02-19','计算机','北京市海淀区'),
('184001','王志勇','男','1997-12-05','电子信息工程',null),
('184002','周潞潞','女','1998-02-24','电子信息工程','上海市浦东区'),
('184004','郑永波','男','1997-09-19','电子信息工程','上海市浦东区');
#查看数据内容/记录
select * from studentinfo;
insert into CourseInfo
values('1004','数据库系统',4),
('1025','物联网技术',3),
('4002','数字电路',3),
('8001','高等数学',4),
('1201','英语',4);
select * from courseinfo;
insert into ScoreInfo
values('181001','1004',95),
('181002','1004',85),
('181003','1004',91),
('184001','4002',93),
('184002','4002',76),
('184004','4002',88),
('181001','8001',94),
('181002','8001',89),
('181003','8001',86),
('184001','8001',85),
('184002','8001',null),
('184004','8001',94),
('181001','1201',92),
('181002','1201',78),
('181003','1201',94),
('184001','1201',85),
('184002','1201',79),
('184004','1201',94);
select * from scoreinfo;
insert into teacherinfo
values('100005','李慧强','男','1968-09-25','计算机学院','北京市海淀区'),
('100024','刘松','男','1976-02-17','计算机学院','北京市海淀区'),
('400021','陈霞飞','女','1975-12-07','通信学院','上海市黄浦区'),
('800004','刘泉明','男','1978-08-16','数学学院','广州市越秀区'),
('120007','张莉','女','1982-03-21','外国语学院','成都市锦江区');
select * from teacherinfo;