MySQL-学⽣表以及课程、⽼师、成绩表的创建学⽣表以及课程、⽼师、成绩表的创建
-- 删除表
drop table if exists score;
drop table if exists student;
drop table if exists course;
drop table if exists teacher;
学⽣表
create table student(
stuNo char(5)primary key,-- 学⽣学号
stuName varchar(32)not null,-- 学⽣姓名
gender char(1)not null default'男',-- 学⽣性别
order by和group by的先后顺序
age int not null-- 学⽣年龄
)charset='utf8';
-- 添加学⽣数据
insert into student(stuNo,stuName,gender,age)values('001','李志','男',14);
insert into student(stuNo,stuName,gender,age)values('002','宋东野','男',23);
insert into student(stuNo,stuName,gender,age)values('003','赵雷','男',34);
mysql面试题学生表insert into student(stuNo,stuName,gender,age)values('004','马頔','男',32);
insert into student(stuNo,stuName,gender,age)values('005','陈粒','⼥',18);
insert into student(stuNo,stuName,gender,age)values('006','筠⼦','⼥',4);
insert into student(stuNo,stuName,gender,age)values('007','⼨铁','男',56);
insert into student(stuNo,stuName,gender,age)values('008','狗⽑','男',47);
insert into student(stuNo,stuName,gender,age)values('009','崔健','男',39);
insert into student(stuNo,stuName,gender,age)values('010','草东','男',40);
insert into student(stuNo,stuName,gender,age)values('011','张悬','⼥',36);
insert into student(stuNo,stuName,gender,age)values('012','撒娇','⼥',25);jenkins自动打包部署
insert into student(stuNo,stuName,gender,age)values('013','宋东野','男',35);
教师表
create table teacher(
tNo char(5)primary key,-- 教师号
tName varchar(32)not null-- 教师名字
)charset='utf8';
-- 添加⽼师数据
insert into teacher(tNo,tName)values('t001','张三');
insert into teacher(tNo,tName)values('t002','李四');
insert into teacher(tNo,tName)values('t003','王⼆');
insert into teacher(tNo,tName)values('t004','王五');
length函数c++课程表
create table course(
cNo char(5)primary key,-- 课程号
cName varchar(32)not null unique,-- 课程名
tNo char(5),-- 教师号
foreign key(tNo)references teacher(tNo)
)charset='utf8';
-
- 添加课程数据
insert into course(cNo,cName,tNo)values('c001','数据结构','t001'); insert into course(cNo,cName,tNo)values('c002','操作系统','t002'); insert into course(cNo,cName,tNo)values('c003','计算机⽹络','t001'); insert into course(cNo,cName,tNo)values('c004','软件⼯程','t003'); insert into course(cNo,cName,tNo)values('c005','计算机组成原理','t002'); insert into course(cNo,cName,tNo)values('c006','数据库系统','t002'); insert into course(cNo,cName,tNo)values('c007','C语⾔','t003');
insert into course(cNo,cName,tNo)values('c008','⾼等数学','t004');
成绩表
create table score(
sNo char(5)not null,-- 教师号
cNo char(5)not null,-- 课程号
score double not null,-- 成绩
primary key(sNo,cNo)
);
-- 添加成绩数据
insert into score(sNo,cNo,score)values('001','c001',56);
insert into score(sNo,cNo,score)values('001','c002',87);
insert into score(sNo,cNo,score)values('001','c003',69);
insert into score(sNo,cNo,score)values('001','c004',92);
insert into score(sNo,cNo,score)values('002','c001',76);
insert into score(sNo,cNo,score)values('002','c003',69);
insert into score(sNo,cNo,score)values('002','c005',90);密码管理系统
insert into score(sNo,cNo,score)values('003','c002',53);
insert into score(sNo,cNo,score)values('003','c003',96);
insert into score(sNo,cNo,score)values('004','c004',67);
insert into score(sNo,cNo,score)values('005','c008',69);
insert into score(sNo,cNo,score)values('005','c007',78);
insert into score(sNo,cNo,score)values('005','c002',70);
insert into score(sNo,cNo,score)values('005','c003',81);
台式电脑结束进程快捷键是什么
insert into score(sNo,cNo,score)values('006','c004',93);
insert into score(sNo,cNo,score)values('006','c008',62);
insert into score(sNo,cNo,score)values('007','c001',58);
insert into score(sNo,cNo,score)values('007','c002',76);
insert into score(sNo,cNo,score)values('008','c003',65);
insert into score(sNo,cNo,score)values('008','c004',89);
insert into score(sNo,cNo,score)values('009','c005',92);
insert into score(sNo,cNo,score)values('009','c006',90);
insert into score(sNo,cNo,score)values('009','c007',42);
insert into score(sNo,cNo,score)values('009','c008',80);
insert into score(sNo,cNo,score)values('010','c002',75);
insert into score(sNo,cNo,score)values('010','c004',69);
insert into score(sNo,cNo,score)values('011','c004',92);
insert into score(sNo,cNo,score)values('011','c005',99);
insert into score(sNo,cNo,score)values('011','c002',100);
insert into score(sNo,cNo,score)values('011','c006',76);
insert into score(sNo,cNo,score)values('012','c003',71);
insert into score(sNo,cNo,score)values('012','c002',83);
insert into score(sNo,cNo,score)values('013','c004',80);
insert into score(sNo,cNo,score)values('013','c007',96);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。