SQL语句上机题

SQL语句上机题

ID:44871006

大小:59.51 KB

页数:6页

时间:2019-10-31

SQL语句上机题_第1页
SQL语句上机题_第2页
SQL语句上机题_第3页
SQL语句上机题_第4页
SQL语句上机题_第5页
资源描述:

《SQL语句上机题》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、习题6.1.3:使用习题5.2.1中提供的数据库模式用SQL语句写出后面的查询,并使用习题5.2.1提供的资料写出查询结果。Product(marker,model,type)PC(model,speed,ram,hd,rd,price)Laptop(model,speed,ram,hd,screen,price)Printer(model,color,type,price)*a)找出所有价格在$1200以下的PC机的型号、速度和硬盘大小。Selectmodel,speed,hdFrompcWherepiece<1

2、200*b)要求同(a),但是重命名列speed为megahertz以及列hd为gigabytes。selectmodel,speedasmegahertz,hdasgigabytesfrompcwhereprice<1200c)找出所有打印机制造厂商。selectdistinctmakerfromproductwheretype=’printer’d)找出价格在$2000以上的手提电脑的型号、内存大小和屏幕尺寸。selectmodel,ram,screenfromlaptopwhereprice>2000*e)找

3、出关系Printer中所有彩色打印机元组,注意属性color是一个布尔类型。selectmodel,type,pricefromprinterwherecolor=’true’f)找出价格少于$2000并拥有12X或16XDVD的PC机的型号、速度和硬盘尺寸。把rd属性看作一个字符串属性。selectmodel,speed,hdfrompcwhereprice<2000andrd=’12xDVD’orrd=’16xDVD’习题6.1.4:基于习题5.2.4给出的数据库模式和资料写出后面的查询语句以及查询结果。Cla

4、sses(class,type,country,numGuns,bore,displacement)Ships(name,class,launched)Battles(name,date)Outcomes(ship,battle,result)a)找出至少装备10门火炮的船只所属类别名和制造国家selectcountry,typefromclasseswherenumGuns>=10b)找出在1918年以前下水的舰船的名字,并且把结果列名改为ShipName。selectnameasshipnamefromship

5、swherelaunched<1918c)找出所有在战役中被击沉的船只和那次战役的名字selectship,battlefromoutcomeswhereresult=’sunk’。d)找出具有相同类别名的所有船只。selectdistinctship1.class,ship1.typefromclassesasship1,classesasship2whereship1.type=ship2.typeandship1.class!=ship2.classorderbytypee)找出所有以”R.”字符开头的船只的

6、名字。selectnamefromshipswherenamelike’R%’!f)找出所有包括三个或三个以上单词的船只名字(例如KingGeorgeV)。selectshipfromoutcomeswhereshiplike‘%%%‘orshiplike‘%%%%’;习题6.2.2:根据习题5.2.1的数据库模式写出下列查询,并用那个习题给出的数据算出查询结果。Product(marker,model,type)PC(model,speed,ram,hd,rd,price)Laptop(model,speed,r

7、am,hd,screen,price)Printer(model,color,type,price)*a)查询硬盘容量至少在30G的手提电脑制造商及电脑的速度。selectmaker,speedfromproduct,laptopwherelaptop.model=product.modelandlaptop.hd>30*b)查询制造商B制造的任意类型的所有产品的型号和价格。selectmodel,pricefrompcwheremodelin(selectmodelfromproductwheremaker=’B

8、’)selectmodel,pricefromprinterwheremodelin(selectmodelfromproductwheremaker=’B’)selectmodel,pricefromlaptopwheremodelin(selectmodelfromproductwheremaker=’B’)a)查询只卖手提电脑不卖PC的厂商。selec

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。