资源描述:
《文华学院数据库实验报告》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、数据库试验报告指导老师:刘小洋班级:电信2班学号:130101021125姓名:肖霖2015年n月29日实验一一.实验目的学会使用SQL语言进行查询二.实验代码及结①selectSNOwhereJNO=jr;②selectSNOfromSPJwhereJNO^JTandpno^Pl7;SN01S12S3©selectSNOfromSPJ,PwhereJNO^JVandSPJ.PNO=P.PNOandP.COLORY红:SelectSNOfromSPJwhereJNOJ1/andPNOIN(selectPNOfromPwhereCOLORS红');—SNO—S12S3©selectJNOfro
2、mSPJwhereSNOIN(selectSNOfromSwhereCITY二'天津")andPNOIN(selectPNOfromPwhereCOLORnotlike"红");JN01J22J1实验二•实验目的学会使用数据定义语言.实验代码及结果①SELECTsname,cityfromzhangl;sna>ecity©SELECTpname,colorzweightfromzhang2;274400111A1A1*4*Qu红绿蓝红蓝红刀刀母栓1£丝轮轮觀螺螺螺凸齿pnamecolorweight①Selectjnofromzhang4wheresno二'SI/;©Selectdistin
3、ctJNOwhereLjnojiJ3L
4、J2zhangl.SNO=zhang4.SNOandzhangl.CITYnotlike'天津1Into」J2J4」J5—©Selectdistinetjnamefromzhang4.SN0=zhangl.SN0andzhangl.CITY^上海';jna>e体厂厂矿Irff车1釧汽丰蛊机三无一©SelectPNO’QTYfromSJ,zhang3whereJNAME=Z三建:(7)Deletefromzhanglwheresno二'S2‘;弄彩响的行数为1行)SN0PN0QTYpl200S3pl200S3p3200S4p5100S5p3200生©Se
5、lectPNO,SJ,zhanglwhereSNO二'三建PNOQTYPl2001pl200P3200p5100Jp3200J⑨Insertintozhang4(SNO,PNO」NO,QTY)values(/S27J6,;P4,;200,);Select*fromzhang4;©Deletefromzhang4wheresno二'S2‘;所影响的行数为6行)11.SelectQT^PNAMEfromzhang4,zhang2wherezhang2.PNO=zhang4.PNOandJNO=,J2,;
6、qtypname100螺栓200螺丝刀100凸轮200齿轮实验三一•实验目的学会使用SQL中
7、的授权和完整性二•实验代码及结果1(1)grantselecton部门to王明;grantselecton职工to王明;©grantinsert,deleteon部门to李勇;Grantinsert,deleteon职工to李勇;©grantselect,updata(工资)on职工to刘星;⑥grantselect,delete,update,inserton部门to周平withgrantoption;grantselect,delete,update,inserton职工to周平withgrantoption;2©revokeselecton部门from王明;revokeselecton
8、职工from王明;©revokeinsert,deleteon部门from李勇;revokeinsert’deleteon职工from李勇;©revokeselect,updata(工资)on职工from刘星;©revokeselect,delete,update,inserton部门from周平cascade;revokeselect,delete,update,inserton职工from周平cascade;3creattablezhigong(职工号char(10)notnull,姓名char(10)notnull,年龄char(10)notnull,constraintclcheck
9、(年龄<=60),职务char(10)notnull,工资char(10)notnull,部门号char(10)notnull,foreignkey(职工号)refereneezhigong(职工号)Jcreatetablenumen(部门号char(10)primarykey,名称char(10)notnull,经理名char(10)notnull,电话char(10)notnull,foreignkey借