欢迎来到天天文库
浏览记录
ID:9219131
大小:237.14 KB
页数:54页
时间:2018-04-23
《数据库系统基础教程第6章课后习题答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、SolutionsChapter66.1.1Attributesmustbeseparatedbycommas.ThushereBisanaliasofA.6.1.2a)SELECTaddressASStudio_AddressFROMStudioWHERENAME='MGM';b)SELECTbirthdateASStar_BirthdateFROMMovieStarWHEREname='SandraBullock';c)SELECTstarNameFROMStarsInWHEREmovieYear=1980ORmovieTitleLIKE'%Love%';However,
2、abovequerywillalsoreturnwordsthathavethesubstringLovee.g.Lover.BelowquerywillonlyreturnmoviesthathavetitlecontainingthewordLove.SELECTstarNameFROMStarsInWHEREmovieYear=1980ORmovieTitleLIKE'Love%'ORmovieTitleLIKE'%Love%'ORmovieTitleLIKE'%Love'ORmovieTitle='Love';d)SELECTnameASExec_NameFROMMo
3、vieExecWHEREnetWorth>=10000000;e)SELECTnameASStar_NameFROMmovieStarWHEREgender='M'ORaddressLIKE'%Malibu%';6.1.3a)SELECTmodel,speed,hdFROMPCWHEREprice<1000;MODELSPEEDHD---------------------10022.1025010031.428010042.8025010053.2025010072.2020010082.2025010092.0025010102.8030010111.8616010122
4、.8016010133.068011record(s)selected.b)SELECTmodel,speedASgigahertz,hdASgigabytesFROMPCWHEREprice<1000;MODELGIGAHERTZGIGABYTES------------------------10022.1025010031.428010042.8025010053.2025010072.2020010082.2025010092.0025010102.8030010111.8616010122.8016010133.068011record(s)selected.c)S
5、ELECTmakerFROMProductWHERETYPE='printer';MAKER-----DDEEEHH7record(s)selected.d)SELECTmodel,ram,screenFROMLaptopWHEREprice>1500;MODELRAMSCREEN------------------2001204820.12005102417.02006204815.42010204815.44record(s)selected.e)SELECT*FROMPrinterWHEREcolor;MODELCASETYPEPRICE----------------
6、--------3001TRUEink-jet993003TRUElaser9993004TRUEink-jet1203006TRUEink-jet1003007TRUElaser2005record(s)selected.Note:ImplementationofBooleantypeisoptionalinSQLstandard(featureIDT031).PostgreSQLhasimplementationsimilartoaboveexample.OtherDBMSprovideequivalentsupport.E.g.InDB2thecolumntypecan
7、bedeclareasSMALLINTwithCONSTRAINTthatthevaluecanbe0or1.TheresultcanbereturnedasBooleantypeCHARusingCASE.CREATETABLEPrinter(modelCHAR(4)UNIQUENOTNULL,colorSMALLINT,typeVARCHAR(8),priceSMALLINT,CONSTRAINTPrinter_ISCOLORCHECK(colorIN(0,1)));SELECTmodel,CASE
此文档下载收益归作者所有