资源描述:
《SQL数据库-毕业外文翻译》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、WorkingwithDatabasesThischapterdescribeshowtouseSQLstatementsinembeddedapplicationstocontroldatabases.Therearethreedatabasestatementsthatsetupandopendatabasesforaccess:SETDATABASEdeclaresadatabasehandle,associatesthehandlewithanactualdatabasefile,andoptionallyassignsoperation
2、alparametersforthedatabase.SETNAMESoptionallyspecifiesthecharactersetaclientapplicationusesforCHAR,VARCHAR,andtextBlobdata.Theserverusesthisinformationtotransliteratefromadatabase’sdefaultcharactersettotheclient’scharactersetonSELECToperations,andtotransliteratefromaclientapp
3、lication’scharactersettothedatabasecharactersetonINSERTandUPDATEoperations.gCONNECTopensadatabase,allocatessystemresourcesforit,andoptionallyassignsoperationalparametersforthedatabase.Alldatabasesmustbeclosedbeforeaprogramends.AdatabasecanbeclosedbyusingDISCONNECT,orbyappendi
4、ngtheRELEASEoptiontothefinalCOMMITorROLLBACKinaprogram.DeclaringadatabaseBeforeadatabasecanbeopenedandusedinaprogram,itmustfirstbedeclaredwithSETDATABASEto:CHAPTER3WORKINGWITHDATABASES.Establishadatabasehandle.Associatethedatabasehandlewithadatabasefilestoredonalocalorremoten
5、ode.Adatabasehandleisaunique,abbreviatedaliasforanactualdatabasename.DatabasehandlesareusedinsubsequentCONNECT,COMMITRELEASE,andROLLBACKRELEASEstatementstospecifywhichdatabasestheyshouldaffect.ExceptindynamicSQL(DSQL)applications,databasehandlescanalsobeusedinsidetransactionb
6、lockstoqualify,ordifferentiate,tablenameswhentwoormoreopendatabasescontainidenticallynamedtables.Eachdatabasehandlemustbeuniqueamongallvariablesusedinaprogram.Databasehandlescannotduplicatehost-languagereservedwords,andcannotbeInterBasereservedwords.Thefollowingstatementillus
7、tratesasimpledatabasedeclaration:EXECSQLSETDATABASEDB1=’employee.gdb’;Thisdatabasedeclarationidentifiesthedatabasefile,employee.gdb,asadatabasetheprogramuses,andassignsthedatabaseahandle,oralias,DB1.Ifaprogramrunsinadirectorydifferentfromthedirectorythatcontainsthedatabasefil
8、e,thenthefilenamespecificationinSETDATABASEmustincludeafullpathname,