DB2实验报告文档格式.docx

上传人:b****6 文档编号:8514835 上传时间:2023-05-11 格式:DOCX 页数:21 大小:389.63KB
下载 相关 举报
DB2实验报告文档格式.docx_第1页
第1页 / 共21页
DB2实验报告文档格式.docx_第2页
第2页 / 共21页
DB2实验报告文档格式.docx_第3页
第3页 / 共21页
DB2实验报告文档格式.docx_第4页
第4页 / 共21页
DB2实验报告文档格式.docx_第5页
第5页 / 共21页
DB2实验报告文档格式.docx_第6页
第6页 / 共21页
DB2实验报告文档格式.docx_第7页
第7页 / 共21页
DB2实验报告文档格式.docx_第8页
第8页 / 共21页
DB2实验报告文档格式.docx_第9页
第9页 / 共21页
DB2实验报告文档格式.docx_第10页
第10页 / 共21页
DB2实验报告文档格式.docx_第11页
第11页 / 共21页
DB2实验报告文档格式.docx_第12页
第12页 / 共21页
DB2实验报告文档格式.docx_第13页
第13页 / 共21页
DB2实验报告文档格式.docx_第14页
第14页 / 共21页
DB2实验报告文档格式.docx_第15页
第15页 / 共21页
DB2实验报告文档格式.docx_第16页
第16页 / 共21页
DB2实验报告文档格式.docx_第17页
第17页 / 共21页
DB2实验报告文档格式.docx_第18页
第18页 / 共21页
DB2实验报告文档格式.docx_第19页
第19页 / 共21页
DB2实验报告文档格式.docx_第20页
第20页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

DB2实验报告文档格式.docx

《DB2实验报告文档格式.docx》由会员分享,可在线阅读,更多相关《DB2实验报告文档格式.docx(21页珍藏版)》请在冰点文库上搜索。

DB2实验报告文档格式.docx

实验地点

机器编号

指导教师

实验时间

年月日时分

一、实验综述

1.实验目的及要求

Thisexerciseisanonlinelabwhichcreatesobjectsusedinadatabase.

Attheendofthelab,studentsshouldbeableto:

•Createtables•Addreferentialintegrityconstraintstoatable

•Createindexes•Addcheckconstraintstoatable

•Createviews•Addtriggerstoatable

•Createanalias•AccessSystemCataloginformationaboutobjects

•RetrieveanXMLdocument

2.实验设备、软件

PC, 

windows 

XPProfessional, 

DB2 

Express-c

二、实验过程(实验步骤、记录、数据、分析)

Section1-CreateTables

1.CreateyourARTISTStable.Thetableshouldhavethefollowingcharacteristics.

•Tableschemaofstudent

•TableNameofartists

•Regulardatatogointablespacedms01

•Indexestogointablespacedms02

•Longdatatogointablespacedms03

•Thecolumnartnoshouldbedefinedasaprimarykey

•Columnsdefinedlikethefollowing:

(artnosmallintnotnull,

namevarchar(50),

classificationchar

(1)notnull,

bioclob(100K)loggedcompact,

pictureblob(500k)notloggedcompact)

Showyourworkbelowbyprintingscreen.

手动创建表空间dms01,dms02,dms03,如下:

执行SQL语句结果如下:

2.VerifythecreationofyourARTISTStableandthetabledescription.

Important:

Ensurethedefinitionofyourtableiscorrect.Itcouldcauseunexpectedfailuresinlaterlabsifyourdefinitionsarenotdonecorrectly.

3.Youwillcreatetheremainderofthetablesrequiredusingascriptfilecalledcrtables.ForWindows,itislocatedintheC:

\labfiles\cf23directory.

ExaminetheDB2statementsinthefileandanswerthefollowingquestions.

InwhichtablespacewillboththeindexesanddatafortableSTOCKbeplacedForCONCERTSForREORDER

4.Executethecrtablesscripttocreatethetables.

Showyourworkbelowbyprintingscreen

5.Verifythatalltables(ALBUMS,STOCK,CONCERTS,andREORDER)werecreatedsuccessfully.

6.Informationabouteachcolumninatablecanbefoundbyaccessingtheview.

EnteraninteractiveSQLstatementtoselectthecolumnsTABNAME,COLNAME,andTYPENAMEfromforalltableswiththeTABSCHEMAof‘student’,orderthedatabyTABNAMEandCOLNO,andpipetheoutputtoafilenamed.

Showyoursqlstatementsandyourworkbelowbyprintingscreenforthelaststep.

7.Checkyouroutputagainstthefile.

Ensurethattherearenodifferencesbetweenyouroutputandthemasteroutputorthefollowinglabsmaynotworkcorrectly!

8.Informationaboutatable'

sdefinitiontoatablespacecanbefoundbyaccessingtheview.EnteranSQLstatementtoselectthecolumnsTABNAME,TBSPACE,andINDEX_TBSPACEfromforalltableswiththeTABSCHEMAof‘student’,orderthedatabyTABNAME,andpipetheoutputtoafilenamed.

9.Checkyouroutputagainstthefile.

Ensurethattherearenodifferencesbetweenyouroutputandthemasteroutput,orthefollowinglabsmaynotworkcorrectly!

10.Grantselectprivilegeontablesthatareownedbystudenttopublicbyexecutingascriptfile,grants(anoperatingsystemcommandfile)forlocaladministration.

Section2-CreateIndexes

1.CreateanindexcalledITEMontheITEMNOcolumninSTOCKtable.

2.CreateauniqueindexcalledITEMNOontheITEMNOcolumninALBUMStable.

3.Selecttheinformationfromthecatalogtablesaboutyourindexes.Thecolumnsyoushouldselectarethefirst18charactersofTABNAME,UNIQUERULE,thefirst18charactersofINDNAME,andthefirst30charactersofCOLNAMESfrom,whereINDSCHEMAisstudent,orderbyTABNAMEandINDNAME.

IfUNIQUERULE="

U"

thenonlyuniquevaluesareallowed.

D"

thenduplicatevaluesareallowed.

P"

thenitisaPrimarykey.

Showyourworkandyournewindexesbelowbyprintingscreen.

4.Usetheselectyouexecutedinthepreviousstepandroutetheoutputto.Checkyourresultsagainst.

Section3-CreateViews

1.Createaviewcalledmusicthatwillselecttitle,classification,namefromalbums,artistswhere=.

2.Createanotherviewcalledinventorybyexecutingthescriptfile,crview.

3.Informationaboutviewscanbefoundintheandviews.TablesandviewsforthecurrentusercanbeshownwithaLISTTABLESstatement.ATYPEofVisaview.

Issueoneofthefollowingstatementsandverifyyourviewsarelisted.

•LISTTABLESstatementOR

•SelectcolumnsTABSCHEMA,TABNAME,andTYPEfromtheviewwithaTABSCHEMAofstudentOR

•SelectcolumnsVIEWSCHEMA,VIEWNAMEfromwithDEFINERofstudent

Section4-CreateAlias

1.CreateanaliascalledsingersfortheARTISTStable,andanaliascalledemptystockfortheREORDERtable.

2.Informationaboutaliasescanbefoundintheview.Tables,views,andaliasesforthecurrentusercanalsobeshownwiththeLISTTABLESstatement.ATYPEofAisanalias.Issueoneofthefollowingstatementsandverifyyouraliasesarelisted.

•LISTTABLESstatementOR

•SelectcolumnsTABNAMEandTYPEfromtheviewwithaTABSCHEMAofstudent.

Section5-AddReferentialIntegrity

1.AltertheALBUMStableanddefinereferentialintegrityrelationshipsithaswithothertables.

•Addaprimarykeyontheitemnocolumn

•AddaforeignkeycalledfkartnoontheartnocolumnwhichreferencesaprimarykeyintheARTISTStable

•ThedeleterulebetweenARTISTSandALBUMSshouldbedeletecascade

2.NowaltertheSTOCKtabletodefineitsreferentialintegrityrelationships,byexecutingthescriptfile,crri.

3.Informationaboutreferentialintegritycanbefoundbyaccessingtheview.Tabledependenciescanalsobeaccessedthroughtheview.EnteraninteractiveSQLstatementtoselectCONSTNAME,TABNAME,REFTABSCHEMA,REFTABNAME,DELETERULEfromtheviewwithaTABSCHEMAofstudent.

4.Runaselecttoretrievethefirst18charactersofTABNAME,andthePARENTSandCHILDRENcolumnsfromwheretheTABSCHEMAisequaltoyouruserid.OrdertheresultsbyTABNAMEanddirectyouroutputtoafilenamed.TheSQLcanbefoundinafilenamed.

Checkyouroutputagainstthefile.

Section6-AddCheckConstraints

1.AltertheSTOCKtableandaddacheckconstrainttoit.Thecheckconstraintshouldhavethefollowingcharacteristics.

•Itshouldbenamedcctype.

•Thebusinessruleitshouldenforceistoonlyallowthevaluesof'

D'

'

C'

or'

R'

inthetypecolumn.

Makesurethealphanumericliteralsaretypedinuppercaseletters.

2.Informationaboutcheckconstraintscanbefoundbyaccessingthe,,,andviews.IssueSQLto:

SelectCONSTNAME,TABNAME,COLNAMEfromtheview.

SelectCONSTNAME,TABNAME,TYPEfromtheview.

IftheTYPE=“K”,thenitisacheckconstraint.IftheType=“P”,thenitisaprimarykey.IftheType=“F”,thenitisaforeignkey.

3.Tocheckyourwork,runaselectstatementthatselectsthefirst100charactersoftheTEXTcolumnfromwhereCONSTNAME='

CCTYPE'

anddirectyouroutputtoafilenamed.TheSQLcanbefoundinafilenamed.Checkyouroutputagainstthefile.

Section7-CreateaTrigger

1.Createatriggerwhichhasthefollowingcharacteristics.

•Itshouldbenamedreorder

•ItshouldfireafteranupdateoftheqtycolumnontheSTOCKtable,ifthenewvalueofqtyis<

=5

•Newshouldbereferencedasn

•ThetriggeredactionshouldinsertthevaluesandcurrenttimestampintotheREORDERtable

•Foreachrowmodedb2sql

2.Informationabouttriggerscanbefoundbyaccessingtheandviews.

EnterinteractiveSQLtoresearchtheREORDERtrigger:

SelectTRIGNAME,TABNAME,andTRIGEVENTcolumnsfromtheview.

TRIGEVENTdescribestheeventthatfiresthetriggerasIforinsert,Dfordelete,orUforupdate.

SelectTRIGNAME,BTYPE,BSCHEMA,BNAMEcolumnsfromview.BTYPEandBSCHEMAgivethenameoftheobjecteddependedonbythetrigger.BTYPEdescribesthetypeofbaseobjectasAforalias,Fforfunctioninstance,Tfortable,orVforview.

Section8-OPTIONAL-WorkingwithXML

1.IftheSAMPLEdatabasehasnotyetbeencreate,createitnow.

2.ConnecttotheSAMPLEdatabase.

3.UseXQUERYandthedb2-fn:

xmlcolumnfunctiontoretrievealloftheXMLdocumentsfromthecustomertable’sinfocolumn.

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2