资源描述:
《数据结库原理实验报告》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验11.1(1)createtablecustomer(cidchar(8)unique,cnamechar(20),citychar(8),discntint,primarykey(cid))createtableagents(aidchar(8)unique,anamechar(20),citychar(8),percentsfloat,primarykey(aid))createtableproducts(pidchar(8)unique,pnamechar(20),primarykey(pid))(2)createtableorders(or
2、danchar(8)unique,monthint,cidchar(8),aidchar(8),pidchar(8),qtyint,dollarsfloat,primarykey(ordan),foreignkey(cid)referencescustomer,foreignkey(aid)referencesagents,foreignkey(pid)referencesproducts)(3)altertableproductsaddcitychar(8)altertableproductsaddquantityintaltertableprodu
3、ctsaddpricefloat(4)createindexxsnooncustomer(cid)createindexxsnoonagents(aid)createindexxsnoonproducts(pid)createindexxsnoonorders(ordan)(5)dropindexcustomer.xsnodropindexagents.xsnodropindexproducts.xsnodropindexorders.xsno1.2(1)select*fromcourses(2)selectsidfromchoices(3)selec
4、tcidfromcourseswherehour<88(4)selectsidfromchoicesgroupbysidhavingsum(score)>400(5)selectcount(cid)fromcourses(6)selectcid,count(sid)fromchoicesgroupbycid(7)selectsidfromchoiceswherescore>60groupbysidhavingcount(cid)>2(8)selectsid,count(cid),avg(score)fromchoicesgroupbysid(9)sel
5、ectstudents.sid,snamefromstudents,choices,courseswherestudents.sid=choices.sidandchoices.cid=courses.cidandcourses.cname='java'(10)selectchoices.cid,choices.scorefromchoices,studentswheresname='sssht'andchoices.sid=students.sidselectcid,scorefromchoiceswheresidin(selectstudents.
6、sidfromstudentswheresname='sssht')(11)selectc1.cnamefromcoursesasc1,coursesasc2wherec1.hour>c2.hourandc2.cname='c++'(12)selectsid,snamefromstudentswheresidin(selectc1.sidfromchoicesasc1,choicesasc2wherec1.score>c2.scoreandc1.cid=c2.cidandc2.sid=(selectsidfromstudentswheresname='
7、znkoo')andc1.cid=(selectcidfromcourseswherecname='c++'))(13)selectsnamefromstudentswheregradein(selectgradefromstudentswheresidin('883794999','850955252'))(14)selectsnamefromstudentswheresidnotin(selectsidfromchoiceswherecid=(selectcidfromcourseswherecname='java'))(15)select*fro
8、mcourseswherehour<=all(selecthourfromcourses)(1