MySQL数据库原理及应用答案实训题.docx





《MySQL数据库原理及应用答案实训题.docx》由会员分享,可在线阅读,更多相关《MySQL数据库原理及应用答案实训题.docx(13页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、MySQL数据库原理及应用答案实训题课后习题名称:学生选课管理系统(stuCourse)/*-项目3-*/*为学生选课管理系统创建名为“stucourse”的数据库。 */create database stucourse;/*为学生选课管理系统数据库(stucourse)创建表,表结构如下,字段名参考表3-26表3-30。(1)创建学生表,学生student (学号,姓名,性别,年龄,系别)。(2)创建教师表,教师teacher (教师编号,姓名,职称,工资,系别,课程号)。(3)创建课程表,课程courseinfo (课程编号,课程名称,教材编号,测试时间,系别)。(4)创建选课表,选课s
2、course (学号,分数,课程编号,教师编号)。(5)创建教材表,教材bookinfo (教材编号,教材名称,出版社,价格,数量) */ create table student( sid char(10) not null primary key, sname char(8) not null, sex char(2) null, age int null, dept varchar(20) null)create table teacher( tid char(10) not null primary key, tname char(8) not null, tpassword char
3、(8) not null, title varchar(20) , salary float, dept varchar(20), cid char(10)create table courseinfo( cid char(10) primary key not null, cname varchar(20), cbook char(10), ctest datetime, dept varchar(10) create table bookinfo ( bid char(10) primary key, bname varchar(30), bpublish varchar(30), bpr
4、ice double, quantity int)create table scourse( sid char(10) not null , score float null, cid char(5) null, tid char(10)/*向上述表中插入数据*/insert into student values(1001, 宋江, 男, 25, 计算机系),(3002, 张明, 男, 23, 生物系 ),(1003, 李小鹏, 男, 26, 计算机系 ),(1004, 郑冬, 女, 25, 计算机系 ),(4005, 李小红, 女, 27, 工商管理 ),(5006, 赵紫月, 女, 24
5、, 外语系); insert into teacher values(3102, 李明, 初级, 2500, 计算机系, C1),(3108, 黄小明, 初级, 4000, 生物系, C3 ),(4105, 张小红, 中级, 3500, 工商管理, C2),(5102, 宋力月, 高级, 3500, 物理系, C4 ),(3106, 赵明阳, 初级, 1500, 地理系, C2),(7108, 张丽, 高级, 3500, 生物系, C3 ),(9103, 王彬, 高级, 3500, 计算机系, C1),(7101, 王力号, 初级, 1800, 生物系, C1 ); insert into c
6、ourseinfo values(C1, 计算机基础, b1231, 2009-4-6, 计算机系),(C2, 工商管理基础, b1232, 2009-7-16, 工商管理),(C3, 生物科学, b1233, 2010-3-6, 生物系),(C4, 大学物理, b1234, 2009-4-26, 物理系 ),(C5, 数据库原理, b1235, 2010-2-6, 计算机系); insert into bookinfo values(b1231, Image Processing, 人民出版社, 34.56, 8 ),(b1232, Signal Processing, 清华出版社, 51.
7、75, 10),(b1233, Digital Signal Processing, 邮电出版社, 48.5, 11 ),(b1234, The Logic Circuit, 北大出版社, 49.2, 40),(b1235, SQL Techniques, 邮电出版社, 65.4, 20 ); insert into scourse values(1001, 87, C1, 3102),(1001, 77, C2, 4105 ),(1001, 63, C3, 3108 ),(1001, 56, C4, 3108),(3002, 78, C3, 3108),(3002, 78, C4, 5102
8、 ),(1003, 89, C1, 9103),(1004, 56, C2, 3106),(4005, 87, C4, 5102 ),(5006, null, C1, 7101);/*在教师表student中,将所有学生年龄增加1岁。*/update student set age=age+1;/*在教师表teacher中,将教师“黄小明”的称职由“初级”改为“中级”。*/update teacher set title=中级 where tname=黄小明;/*在教师表teacher中,删除张小红教师的记录。*/delete from teacher where tname=张小红/*在教材
9、表bookinfo中,删除“邮电出版社”的图书*/delete from bookinfo where bname=邮电出版社;/*-项目4-*/*查询全体学生的学号、姓名和年龄。*/select sid,sname,age from student/*查询选修了课程的学生号。*/select distinct sid from scourse/*查询选修课程号C3的学号和成绩。*/select sid,scorefrom scourse where cid=C3/*查询成绩高于85分的学生的学号、课程号和成绩。*/select sid,cid,score from scourse where
10、 score85/*查询没有选修C1,也没有选修C2的学生的学号、课程号和成绩。*/select sid,cid,scorefrom scoursewhere cid not in(C1,C2)select sid,cid,scorefrom scoursewhere cid!=C1 and cid!=C2/*查询工资在15002000之间的教师的教师号、姓名及职称。*/select tid,tnname,title from teacher where salary=1500 and salary85/*查询选课在二门以上且各门课均及格的学生的学号及其总成绩,查询结果按总成绩降序列出。*/s
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MySQL 数据库 原理 应用 答案 实训题

限制150内