跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案

上传人:夏** 文档编号:543627938 上传时间:2023-01-26 格式:DOC 页数:36 大小:329.50KB
返回 下载 相关 举报
跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案_第1页
第1页 / 共36页
跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案_第2页
第2页 / 共36页
跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案_第3页
第3页 / 共36页
跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案_第4页
第4页 / 共36页
跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案_第5页
第5页 / 共36页
点击查看更多>>
资源描述

《跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案》由会员分享,可在线阅读,更多相关《跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案(36页珍藏版)》请在金锄头文库上搜索。

1、1.1 跟我学Oracle从入门到精通培训教程Oracle课程的课后作业及答案1.1.1 课后作业1及答案1、按照如下的要求设计一个数据库中的三个数据库表结构及定义每个数据库表的完整性要求(最好在Oracle和MySQL中同时实现)(1)Student学生数据库表的结构Student(Sno,Sname,Ssex,Sage,Sdept),其中属性Sno、Sname、Ssex、Sage和Sdept分别表示学号、姓名、性别、年龄和所在系。该Student数据库表的完整性要求如下:lSno为主键lSname不为空lSsex只能为“男”或者“女”lSage只能在15-35岁之间lSdept的默认值为软

2、件学院(2)Course课程信息数据库表的结构Course(Cno,Cname,Cpno,Ccredit),其中属性Cno、Cname、Cpno和Ccredit分别表示课程号、课程名、先修课号和学分。该Course数据库表的完整性要求如下:lCno为主键lCname不为空lCpno 不为空,并且只能在110之间lCcredit不为空,并且只能是 1、2、4三种可能的值(3)CourseResult学生选课结果信息数据库表结构CourseResult(Sno,Cno,Grade),其中属性Sno、Cno和Grade分别表示学号、课程号和成绩。该CourseResult数据库表的完整性要求如下:l

3、主键为复合主键(Sno,Cno),不能为空值lGrade为百分制成绩(0-100之间)2、对上面的Student、Course和CourseResult三个数据库表按照如下的要求设计出相关的查询SQL语句(高级部分,其中需要用到明天学习的内容,可以提前预习)(1)查询每个学生(姓名)选了哪门课(课程名)得了多少分?(2)查询计算机系中男生、女生分别多少人?(3)查询选修人数在三人(包括三人)的课程(4)查询哪个学生没有选课?(使用not in、not exists以及外关联三种方法)-创建学生表create table student( sno number primary key, snam

4、e varchar(20) , ssex char(2) check(ssex in(男,女), sage number(3) check(sage18 and sage0 and ccredit0 and grade =3);-查询计算机系中的男生、女生分别多少人(1)不采用分组实现select count(ssex) from student where ssex=男;select count(ssex) from student where ssex=女;(2)采用分组实现,并应用having条件select count(*) from student group by ssex,sde

5、pt having sdept=计算机系;(3)采用分组实现,并应用where条件select count(*) from student where sdept=计算机系group by ssex;-查询哪个学生没有选课select * from student where sno not in (select CourseResult.sno from CourseResult);select * from student where not exists (select CourseResult.sno from CourseResult);1.1.2 课后作业2及答案1、已知客户表cu

6、stomer的结构为(customerID、name、address)、登陆流水表loginLanding的结构为(id、customerID、time)、购物流水表shopLanding的结构为(id、customerID、time、productid、productnum)(1)获得每个客户的最新登陆时间time、姓名name和客户customerID等信息(2)采用一条SQL语句实现查最新登陆并且已经购买商品的客户的customerID和name、登陆的时间time等信息create table customer( customerid number primary key not nu

7、ll, name varchar(20) , address varchar(20);create table loginlanding( id number primary key not null, customerid number references customer(customerid), time date default sysdate );create table shoplanding( id number references loginlanding(id), customerid number references customer(customerid), time date default sysdate, productid number , productnum number, primary key (productid);insert into customer (customerid,name,address) values(001,张三,河北省);insert into customer (customerid,name,address) values(002,李四,河北省);insert into customer (customerid,name,add

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号