SQL数据库中英文对照外文翻译文献.docx

上传人:b****3 文档编号:10697556 上传时间:2023-05-27 格式:DOCX 页数:29 大小:27.37KB
下载 相关 举报
SQL数据库中英文对照外文翻译文献.docx_第1页
第1页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第2页
第2页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第3页
第3页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第4页
第4页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第5页
第5页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第6页
第6页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第7页
第7页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第8页
第8页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第9页
第9页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第10页
第10页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第11页
第11页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第12页
第12页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第13页
第13页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第14页
第14页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第15页
第15页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第16页
第16页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第17页
第17页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第18页
第18页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第19页
第19页 / 共29页
SQL数据库中英文对照外文翻译文献.docx_第20页
第20页 / 共29页
亲,该文档总共29页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

SQL数据库中英文对照外文翻译文献.docx

《SQL数据库中英文对照外文翻译文献.docx》由会员分享,可在线阅读,更多相关《SQL数据库中英文对照外文翻译文献.docx(29页珍藏版)》请在冰点文库上搜索。

SQL数据库中英文对照外文翻译文献.docx

SQL数据库中英文对照外文翻译文献

中英文对照外文翻译文献

(文档含英文原文和中文翻译)

WorkingwithDatabases

ThischapterdescribeshowtouseSQLstatementsinembeddedapplicationstocontroldatabases.Therearethreedatabasestatementsthatsetupandopendatabasesforaccess:

SETDATABASEdeclaresadatabasehandle,associatesthehandlewithanactualdatabasefile,andoptionallyassignsoperationalparametersforthedatabase.

SETNAMESoptionallyspecifiesthecharactersetaclientapplicationusesforCHAR,VARCHAR,andtextBlobdata.Theserverusesthisinformationtotransliteratefromadatabase’sdefaultcharactersettotheclient’scharactersetonSELECToperations,andtotransliteratefromaclientapplication’scharactersettothedatabasecharactersetonINSERTandUPDATEoperations.

gCONNECTopensadatabase,allocatessystemresourcesforit,andoptionallyassignsoperationalparametersforthedatabase.Alldatabasesmustbeclosedbeforeaprogramends.AdatabasecanbeclosedbyusingDISCONNECT,orbyappendingtheRELEASEoptiontothefinalCOMMITorROLLBACKinaprogram.

Declaringadatabase

Beforeadatabasecanbeopenedandusedinaprogram,itmustfirstbedeclaredwithSETDATABASEto:

CHAPTER3WORKINGWITHDATABASES.Establishadatabasehandle.Associatethedatabasehandlewithadatabasefilestoredonalocalorremotenode.Adatabasehandleisaunique,abbreviatedaliasforanactualdatabasename.DatabasehandlesareusedinsubsequentCONNECT,COMMITRELEASE,andROLLBACKRELEASEstatementstospecifywhichdatabasestheyshouldaffect.ExceptindynamicSQL(DSQL)applications,databasehandlescanalsobeusedinsidetransactionblockstoqualify,ordifferentiate,tablenameswhentwoormoreopendatabasescontainidenticallynamedtables.

Eachdatabasehandlemustbeuniqueamongallvariablesusedinaprogram.Databasehandlescannotduplicatehost-languagereservedwords,andcannotbeInterBasereservedwords.Thefollowingstatementillustratesasimpledatabasedeclaration:

EXECSQL

SETDATABASEDB1=’employee.gdb’;

Thisdatabasedeclarationidentifiesthedatabasefile,employee.gdb,asadatabasetheprogramuses,andassignsthedatabaseahandle,oralias,DB1.

Ifaprogramrunsinadirectorydifferentfromthedirectorythatcontainsthedatabasefile,thenthefilenamespecificationinSETDATABASEmustincludeafullpathname,too.Forexample,thefollowingSETDATABASEdeclarationspecifiesthefullpathtoemployee.gdb:

EXECSQL

SETDATABASEDB1=’/interbase/examples/employee.gdb’;

Ifaprogramandadatabasefileitusesresideondifferenthosts,thenthefilenamespecificationmustalsoincludeahostname.ThefollowingdeclarationillustrateshowaUnixhostnameisincludedaspartofthedatabasefilespecificationonaTCP/IPnetwork:

EXECSQL

SETDATABASEDB1=’jupiter:

/usr/interbase/examples/employee.gdb’;

OnaWindowsnetworkthatusestheNetbeuiprotocol,specifythepathasfollows:

EXECSQL

SETDATABASEDB1=’//venus/C:

/Interbase/examples/employee.gdb’;

DECLARINGADATABASE

EMBEDDEDSQLGUIDE37

Declaringmultipledatabases

AnSQLprogram,butnotaDSQLprogram,canaccessmultipledatabasesatthesametime.Inmulti-databaseprograms,databasehandlesarerequired.Ahandleisusedto:

1.Referenceindividualdatabasesinamulti-databasetransaction.

2.Qualifytablenames.

3.SpecifydatabasestoopeninCONNECTstatements.

IndicatedatabasestoclosewithDISCONNECT,COMMITRELEASE,andROLLBACKRELEASE.

DSQLprogramscanaccessonlyasingledatabaseatatime,sodatabasehandleuseisrestrictedtoconnectingtoanddisconnectingfromadatabase.

Inmulti-databaseprograms,eachdatabasemustbedeclaredinaseparateSETDATABASEstatement.Forexample,thefollowingcodecontainstwoSETDATABASEstatements:

...

EXECSQL

SETDATABASEDB2=’employee2.gdb’;

EXECSQL

SETDATABASEDB1=’employee.gdb’;

...

4Usinghandlesfortablenames

Whenthesametablenameoccursinmorethanonesimultaneouslyaccesseddatabase,adatabasehandlemustbeusedtodifferentiateonetablenamefromanother.Thedatabasehandleisusedasaprefixtotablenames,andtakestheformhandle.table.

Forexample,inthefollowingcode,thedatabasehandles,TESTandEMP,areusedtodistinguishbetweentwotables,eachnamedEMPLOYEE:

...

EXECSQL

DECLAREIDMATCHCURSORFOR

SELECTTESTNOINTO:

matchidFROMTEST.EMPLOYEE

WHERETESTNO>100;

EXECSQL

DECLAREEIDMATCHCURSORFOR

SELECTEMPNOINTO:

empidFROMEMP.EMPLOYEE

WHEREEMPNO=:

matchid;

...

CHAPTER3WORKINGWITHDATABASES

38INTERBASE6

IMPORTANT

ThisuseofdatabasehandlesappliesonlytoembeddedSQLapplications.DSQLapplicationscannotaccessmultipledatabasessimultaneously.

4Usinghandleswithoperations

Inmulti-databaseprograms,databasehandlesmustbespecifiedinCONNECTstatementstoidentifywhichdatabasesamongseveraltoopenandprepareforuseinsubsequenttransactions.

DatabasehandlescanalsobeusedwithDISCONNECT,COMMITRELEASE,andROLLBACK

RELEASEtospecifyasubsetofopendatabasestoclose.ToopenandprepareadatabasewithCONNECT,see“Openingadatabase”onpage41.TocloseadatabasewithDISCONNECT,COMMITRELEASE,orROLLBACKRELEASE,see“Closingadatabase”onpage49.Tolearnmoreaboutusingdatabasehandlesintransactions,see“Accessinganopendatabase”onpage48.

Preprocessingandruntimedatabases

Normally,eachSETDATABASEstatementspecifiesasingledatabasefiletoassociatewithahandle.Whenaprogramispreprocessed,gpreusesthespecifiedfiletovalidatetheprogram’stableandcolumnreferences.Later,whenauserrunstheprogram,thesamedatabasefileisaccessed.Differentdatabasescanbespecifiedforpreprocessingandruntimewhennecessary.4UsingtheCOMPILETIMEclauseAprogramcanbedesignedtorunagainstanyoneofseveralidenticallystructureddatabases.Inothercases,theactualdatabasethataprogramwilluseatruntimeisnotavailablewhenaprogramispreprocessedandcompiled.Insuchcases,SETDATABASEcanincludeaCOMPILETIMEclausetospecifyadatabaseforgpretotestagainstduringpreprocessing.Forexample,thefollowingSETDATABASEstatementdeclaresthatemployee.gdbistobeusedbygpreduringpreprocessing:

EXECSQL

SETDATABASEEMP=COMPILETIME’employee.gdb’;

IMPORTANT

ThefilespecificationthatfollowstheCOMPILETIMEkeywordmustalwaysbeahard-coded,quotedstring.

DECLARINGADATABASE

EMBEDDEDSQLGUIDE39

WhenSETDATABASEusestheCOMPILETIMEclause,butnoRUNTIMEclause,anddoesnotspecifyadifferentdatabasefilespecificationinasubsequentCONNECTstatement,thesamedatabasefileisusedbothforpreprocessingandruntime.TospecifydifferentpreprocessingandruntimedatabaseswithSETDATABASE,useboththeCOMPILETIMEand

RUNTIMEclauses.

4UsingtheRUNTIMEclause

Whenadatabasefileisspecifiedforuseduringpreprocessing,SETDATABASEcanspecifyadifferentdatabasetouseatruntimebyincludingtheRUNTIMEkeywordandaruntimefilespecification:

EXECSQL

SETDATABASEEMP=COMPILETIME’employee.gdb’

RUNTIME’employee2.gdb’;

ThefilespecificationthatfollowstheRUNTIMEkeywordcanbeeitherahard-coded,quotedstring,orahost-languagevariable.Forexample,thefollowingCcodefragmentpromptstheuserforadatabasename,andstoresthenameinavariablethatisusedlaterinSETDATABASE:

...

chardb_name[125];

...

printf("Enterthedesireddatabasename,includingnodeandpath):

\n");gets(db_name);

EXECSQL

SETDATABASEEMP=COMPILETIME’employee.gdb’RUNTIME:

db_name;

...

Notehost-languagevariablesinSETDATABASEmustbepreceded,asalways,byacolon.

ControllingSETDATABASEscope

Bydefault,SETDATABASEcreatesahandlethatisglobaltoallmodulesinanapplication.

Aglobalhandleisonethatmaybereferencedinallhost-languagemodulescomprisingtheprogram.SETDATABASEprovidestwooptionalkeywordstochangethescopeofadeclaration:

gSTATIClimitsdeclarationscopetothemodulecontainingtheSETDATABASEstatement.NootherprogrammodulescanseeoruseadatabasehandledeclaredSTATIC.

CHAPTER3WORKINGWITHDATABASES

40INTERBASE6

EXTERNnotifiesgprethataSETDATABASEstatementinamoduleduplicatesaglobally-declareddatabaseinanothermodule.IftheEXTERNkeywordisused,thenanothermodulemustcontaintheactualSETDATABASEstatement,oranerroroccursduringcompilation.

TheSTATICkeywordisusedinamulti-moduleprogramtorestrictdatabasehandleaccesstothesinglemodulewhereitisdeclared.Thefollowingexampleillustratestheuseofthe

STATICkeyword:

EXECSQL

SETDATABASEEMP=STATIC’employee.gdb’;

TheEXTERNkeywordisusedinamulti-moduleprogramtosignalthatSETDATABASEinonemoduleisnotanactualdeclaration,butreferstoadeclarationmadeinadifferentmodule.Gpreusesthisinformationduringpreprocessing.ThefollowingexampleillustratestheuseoftheEXTERNkeyword:

EXECSQL

SETDATABASEEMP=EXTERN’employee.gdb’;

IfanapplicationcontainsanEXTERNreference,thenwhenitisusedatruntime,theactualSETDATABASEdeclarationmustbeprocessedfirst,andthedatabaseconnectedbeforeothermodulescanaccessit.

AsingleSETDATABASEstatementcancontaineithertheSTATICorEXTERNkeyword,butnotboth.AscopedeclarationinSETDATABASEappliestobothCOMPILETIMEandRUNTIMEdatabases.

Specifyingaconnectioncharacterset

Whenaclientapplicationconnectstoadatabase,itmayhaveitsowncharactersetrequirements.Theserverprovidingdatabaseaccesstotheclientdoesnotknowabouttheserequirementsunlesstheclientspecifiesthem.TheclientapplicationspecifiesitscharactersetrequirementusingtheSETNAMESstatementbeforei

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

当前位置:首页 > 自然科学 > 物理

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

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