收藏 分销(赏)

实验6:使用索引-视图及批量(答案).doc

上传人:仙人****88 文档编号:7387489 上传时间:2025-01-02 格式:DOC 页数:2 大小:23KB 下载积分:10 金币
下载 相关 举报
实验6:使用索引-视图及批量(答案).doc_第1页
第1页 / 共2页
实验6:使用索引-视图及批量(答案).doc_第2页
第2页 / 共2页
本文档共2页,全文阅读请下载到手机保存,查看更方便
资源描述
GDOU-B-11-112 广东海洋大学学生实验报告书 实验名称 实验四:使用子查询 课程名称 数据库原理与设计 成绩 学院(系) 软件学院 专业 计算机软件工程 班级 学生姓名 学号 实验地点 实验日期 实验目的: 1. 掌握带谓词IN的子查询; 2. 掌握带存在量词的子查询; 3. 掌握使用比较运算符的子查询; 4. 掌握使用限量谓词的子查询; 5. 综合运用所学知识实现查询; 6. 掌握SELECT INTO语句和UNION语句 实验内容 完成在在Recruitment,GlobalToyz和Student数据库基础上的查询,按要求完成给出的下列题目,要求写出相应数据库的查询语句(SELECT)。 1. 将售价大于9元的玩具信息拷贝到一张局部临时表中,该表仅在一次会话中存在。 2. 查询截止日期(dExpiryDate)在2001年5月的订购者(Shopper)的姓名和所在城市。 3. 根据玩具品牌统计每种品牌的平均价格,输出其中平均价格最高的品牌ID以及平均价格。 4. 检索每一类(类别用cCategoryId表示)玩具里价格最高的玩具的名称。 5. 检索价格最高的玩具的品牌(品牌为Brand)名称。 6. 要求必须用带EXISTS量词的嵌套查询实现,检索和‘David Cooper’住在同一个州的订购者(Shopper)的姓和名。 7. 检索‘California’州的订购者(Shopper)和接收人(Recipient)的姓名以及住址。 8. 检索订购者的人数,他们和‘Lisa Lee’使用同一种类型的信用卡。 9. 检索订购了玩具品牌为‘Largo’的订购者的姓和名。(多层嵌套查询实现) 10. 检索价格不低于所有品牌ID为‘005’的玩具的名称。 指导教师 日期 注:请用A4纸书写,不够另附纸。 第   页,共   页 1. select * into #temptoys from toys where mToyRate>9 2. select vFirstname,vLastname,cCity from Shopper where datepart(yy,dExpiryDate)=2001 and datepart(mm,dExpirydate)=5 3. select cBrandId,Avg(mToyrate) from Toys Group by cBrandId having avg(mToyrate)>= all(select avg(mToyrate) from toys group by cBrandId) 4. select vToyname from Toys a where mToyrate=(select max(mToyrate) from Toys b where b.cCategoryId=a.cCategoryId) 5. select cBrandName from ToyBrand where cBrandId in(select cBrandId from Toys where mToyrate=(select max(mToyrate) from toys)) 6. select vFirstname,vLastname from Shopper a where exists(select * from Shopper b where vFirstname=’David’ and vLastname=’Cooper’ and b.cState=a.cState) 7. select vFirstname,vLastname,vAddress from Shopper where cState=’California’union select vFirstname,vLastname,vAddress from Recipient where cState=’California’ 8. select count(*) from shopper where vCreditCardType in(select vCreditCardType from Shopper where vFirstname=’Lisa’ and vLastname=’Lee’ 9. select vFirstname,vLastname from Shopper where cShopperId in(select cShopperId from orders where cOrderNo in(select cOrderNo from Orderdetail where cToyId in (select cToyId from toys where cBrandId in(select cBrandid from toybrand where cBrandName=’Largo’)))) 10. select vToyname from toys where mToyrate>=some(select mToyrate from Toys where cBrandid=’005’)
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 小学其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服