《SQLServer数据库上机实验报告.docx》由会员分享,可在线阅读,更多相关《SQLServer数据库上机实验报告.docx(18页珍藏版)》请在优知文库上搜索。
1、数据库系统原理上机试验报告学号:1120131743姓名:谈兆年班级:07111301一、试验目的与要求:娴熟运用SQ1.语句驾驭关系模型上的完整性约束机制二、试验内容1:利用SQ1.语句创建Employee数据库CREATEDATABASEEmployee;*fl(AsIAD8图)三XF住4、3Q立1*X案70技制日棺曰S0HoKl5twIiIiIiEJs nE333 静务 二JK!图二J亶电e2j三Cj支内多3BQjHrt*SvMmdbC*inKrMB*.*rownSQlServersSQlServe*ttZDH-)7(Wtndom*T)BCAitrfVarchar10Null职称Dept
2、noChar4NotNull部门代码.外键(参照dep表)表2salary表结泡字段名数据类型字段长度允许空否字段说明P_noChar6NoNull工号,主说.外根(参照PCNOn表)BaseDcc5Null基本工资BonusDw5Null奖金,要求50FactDec5Null突发工资=基本工资+奖金MonthInt2NotNull.Binhda3DatctinNulhProfVARCHAR(IO)NuI1.DcptnoCHAR(4)NotNull.FOREIGNKEY(Deptno)REFERENCESdcp(Dcptn50).EactasBasc+Bonus.MonthIntNotNull
3、,FOREIGNKEY(P.no)REFERENCESperson(P_i)o);结果:*i话蝴T-JSfiaHHrJMuIjMsQ三qHrorvw*HPR13IZSI60C4O空A3S3mn需尸MiyZnlftC4NjbM(VnMMIXWXI日%2)OWerwvrtcW4I2*I2UtM*二“*fch林oeA12WEZ110*m4IiJ少不awt*pneJSM口“滴2$W4I6UZWi2*n3*JlexfvBa)Gel2*12Z3&或3X3e2ftl2,H1PX5!rP三3tWi200.1212C,Artflnr*v*ve*r柿MaHKI汴1?QX11*口卜代Wl291i描U21*mMIKU
4、?田UgvW*M4W12SUFwt*.a*wM*a4wmtW”12*12)crpW5crw*CH3r(Wvw*1*t*crec少(imATE11t-04r?,、a,。S3:利用SQ1.语句向表person%salary和dept中插入数据。做法:按表4、表5、表6中的数据插入。表4表PCrson的数据P_noP_nameSexBirthDaleProfDeptnoOooOOl王云男1973-4-7锻Oool000002谢志又男1975-2-14中级Oool000003李浩然男1970-8-25高级OOO2(XXXXM震小玲女1979-8-6初级OoO2OWO()5梁玉琼女1970-8-25中级
5、OoO3O(XXj()6罗向东男1979-5-11初级OOO3000007肖家庆男1963-7-14高级Ooo3表5表SaIary中的数据P_noBaseBonusFactS_nonth00000121(X)3001(XXXX)2J8)3001OoooO32800280100000425002501(XXXX)52300275IOoOoo61750130I000007240()210I表6表depl的数据DepinoDname0l人事都Oa)2叼务部OoO3市场部程序为:INSERTINTOdep(Dep(11o.Dname)VaIUCSfoo01;人事部NINSERTINTO(Icpt(De
6、ptno1Dnamc)VUlUCS(02.财务95):INSERTINTOdcpl(Deptno.Dnanc)ValUC“0003Vm场部.):程序为:INSERTINTOpcnon(P_no,P_namc,Scx,Binhh(cTiof,Deptno)vluescooooo?王云.男9797;中级;OOOr);INSERTINTOpcnion(P_no.P_namc.Scx.Birthdatc.Prof.DcpiHi)VA1.UESCoOOo02,潮志文.男;1975-2-14:中级;OOOI,INSERTINTOPeniOmP_no.P_narne.Sex.Birthdale.Prof.D
7、epn)VA1.UESCoooo03,等浩然,男*1970825;高级,0002%INSERTINTOenon(P-no.P-name.Sex.Birthdae.Pf.DeX!)o)VA1.UESCOa)Oo4,修小玲7,19投初级:0002);INSERTINTOpenion(P_no,P_name,Sex.Birthtia(e.Ptf.Dexno)VA1.UES(OOOoO5;梁玉琼.女,l970-8-2S:中级.0003);INSERTINTOpcnion(P_no,P_namc.Scx.Binhdatc,Prof.Dcpon(P_no.P_nanc.Sex.Binhdatc.P11f.
8、Dcptno)VA1.UESfOoOOO7,肖家庆,明;1963-7-14;高级Ooo3);UziTperanWflMRJK,位置基XmPiOyee飞ZDMw”上e9三三Ep3:aXfi三%PAQIfls.xIBirthdnUIProfOOOOOl1973-4-7COOl000002W5-2-KOOOlOOooo319T0-2502o019T9-80002OCO5WQ-8-25O3OeocD6罗向东19T9-5-110003*ooo011肖家庆1963-7-K0003程序为:INSERTINTOsalar)(P_no,Basc.Bonus.MonthValuesc(MXMX)r;2oov3ov
9、r);INSERTINTOsalar),(P_no.Basc.Bonus.MonlhVA1.uESa)Oooo2:18(X),.3(X),);INSERTINTOsalarVA1.UES(XXXX)6.,175O.l30.T:INSERTINTOsalarj,(P_no.B;ise.BonusA1onth)VA1.UES(000007,2400.21071);,像看是FmpIoyceMZDH-38-图I亘亘画巨P5!咳,21打球但%PnoIBonusIFactIHoMhO(XX)Ol21002400I000002182100!0000032800306010(X0042S0027501Oax)O523825751000006175018801OOOOOT2400