资源描述:
《SQL数据库-毕业外文翻译》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、WorkingwithDatabasesThischapterdescribeshowtouseSQLstatementsinembeddedapplicationstocontroldatabases.Therearethreedatabasestatementsthatsetupandopendatabasesforaccess:SETDATABASEdeclaresadatabasehandle,associatesthehandlewithanactualdatabasefile,andoptionallyassignsop
2、erationalparametersforthedatabase.SETNAMESoptionallyspecifiesthecharactersetaclientapplicationusesforCHAR,VARCHAR,andtextBlobdata.Theserverusesthisinformationtotransliteratefromadatabase’sdefaultcharactersettotheclient’scharactersetonSELECToperations,andtotransliterate
3、fromaclientapplication’scharactersettothedatabasecharactersetonINSERTandUPDATEoperations.gCONNECTopensadatabase,allocatessystemresourcesforit,andoptionallyassignsoperationalparametersforthedatabase.Alldatabasesmustbeclosedbeforeaprogramends.AdatabasecanbeclosedbyusingD
4、ISCONNECT,orbyappendingtheRELEASEoptiontothefinalCOMMITorROLLBACKinaprogram.DeclaringadatabaseBeforeadatabasecanbeopenedandusedinaprogram,itmustfirstbedeclaredwithSETDATABASEto:CHAPTER3WORKINGWITHDATABASES.Establishadatabasehandle.Associatethedatabasehandlewithadatabas
5、efilestoredonalocalorremotenode.Adatabasehandleisaunique,abbreviatedaliasforanactualdatabasename.DatabasehandlesareusedinsubsequentCONNECT,COMMITRELEASE,andROLLBACKRELEASEstatementstospecifywhichdatabasestheyshouldaffect.ExceptindynamicSQL(DSQL)applications,databasehan
6、dlescanalsobeusedinsidetransactionblockstoqualify,ordifferentiate,tablenameswhentwoormoreopendatabasescontainidenticallynamedtables.Eachdatabasehandlemustbeuniqueamongallvariablesusedinaprogram.Databasehandlescannotduplicatehost-languagereservedwords,andcannotbeInterBa
7、sereservedwords.Thefollowingstatementillustratesasimpledatabasedeclaration:EXECSQLSETDATABASEDB1=’employee.gdb’;Thisdatabasedeclarationidentifiesthedatabasefile,employee.gdb,asadatabasetheprogramuses,andassignsthedatabaseahandle,oralias,DB1.Ifaprogramrunsinadirectorydi
8、fferentfromthedirectorythatcontainsthedatabasefile,thenthefilenamespecificationinSETDATABASEmustincludeafullpathname,