资源描述:
《SQL数据库-毕业外文翻译》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、WorkingwithDatabasesThischapterdescribeshowtouseSQLstatementsinembeddedapplicationstocontroldatabases.Therearethreedatabasestatementsthatsetupandopendatabasesforaccess:SETDATABASEdeclaresadatabasehandle,associatesthehandlewithanactualdatabasefile,andopt
2、ionallyassignsoperationalparametersforthedatabase.SETNAMESoptionallyspecifiesthecharactersetaclientapplicationusesforCHAR,VARCHAR,andtextBlobdata.Theserverusesthisinformationtotransliteratefromadatabase’sdefaultcharactersettotheclient’scharactersetonSEL
3、ECToperations,andtotransliteratefromaclientapplication’scharactersettothedatabasecharactersetonINSERTandUPDATEoperations.gCONNECTopensadatabase,allocatessystemresourcesforit,andoptionallyassignsoperationalparametersforthedatabase.Alldatabasesmustbeclose
4、dbeforeaprogramends.AdatabasecanbeclosedbyusingDISCONNECT,orbyappendingtheRELEASEoptiontothefinalCOMMITorROLLBACKinaprogram.DeclaringadatabaseBeforeadatabasecanbeopenedandusedinaprogram,itmustfirstbedeclaredwithSETDATABASEto:CHAPTER3WORKINGWITHDATABASES
5、.Establishadatabasehandle.Associatethedatabasehandlewithadatabasefilestoredonalocalorremotenode.Adatabasehandleisaunique,abbreviatedaliasforanactualdatabasename.DatabasehandlesareusedinsubsequentCONNECT,COMMITRELEASE,andROLLBACKRELEASEstatementstospecif
6、ywhichdatabasestheyshouldaffect.ExceptindynamicSQL(DSQL)applications,databasehandlescanalsobeusedinsidetransactionblockstoqualify,ordifferentiate,tablenameswhentwoormoreopendatabasescontainidenticallynamedtables.Eachdatabasehandlemustbeuniqueamongallvar
7、iablesusedinaprogram.Databasehandlescannotduplicatehost-languagereservedwords,andcannotbeInterBasereservedwords.Thefollowingstatementillustratesasimpledatabasedeclaration:EXECSQLSETDATABASEDB1=’employee.gdb’;Thisdatabasedeclarationidentifiesthedatabasef
8、ile,employee.gdb,asadatabasetheprogramuses,andassignsthedatabaseahandle,oralias,DB1.Ifaprogramrunsinadirectorydifferentfromthedirectorythatcontainsthedatabasefile,thenthefilenamespecificationinSETDATABASEmustincludeafullpathname,