资源描述:
《最新A first course in database systems(8)复习进程.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、8SystemAspectsofSQLSQLinaprogrammingenvironmentTransactionsinSQLSecurityandUserAuthorization__________________________________________________8.1SQLinaProgrammingEnvironmentWhydoweneedotherprogramminglanguagesindatabaseapplicationsystems?Adatabasejustprovidessharingd
2、atasourceforaspecialenvironment.ManyuserscannotuseSQLtomanipulatedatabaseinclient(客户端)directly.Manyconventionalprogramminglanguagesallowconnectionandmanipulationofdatabase.Java,PowerBuilder,Delphi,C/C++,VB…__________________________________________________8.1SQLinaPr
3、ogrammingEnvironmentJavaprogram1JDBCdatabaseJDBCODBCJDBCJavaclassWebServerBrowserDBAJavaprogram2Delphiprogram1__________________________________________________8.1SQLinaProgrammingEnvironment宿主语言+嵌套SQL编译预处理宿主语言+函数调用函数库目标代码编译包含SQL语句的典型编程系统的框架如下:_______________________
4、___________________________8.1SQLinaProgrammingEnvironmentThedifferenceofSQLandconventional(传统的)programminglanguage:SQLusestherelationaldatamodel.Conventionalprogramminglanguagesuseadatamodelwithintegers,reals,characters,andsoon.impedancemismatch(匹配失衡)Howtomanipulate
5、databasebyconventionalprogramminglanguages?connecttodatabase,buildasession.sendasequenceofSQLstatements,receiveanddealwiththeresult.closethesession.__________________________________________________8.1SQLinaProgrammingEnvironmentTheSQL/HostLanguageInterface:DeclareSh
6、aredVariables。EXECSQLBEGINDECLARESECTION;charstudioName[50],studioAddr[256];charSQLSTATE[6];EXECSQLENDDECLARESECTION;UseEmbedSQL。EXECSQLINSERTINTOStudio(name,address)VALUES(:studioName,:studioAddr);UsePrecompilerstatement,EXECSQL。UseSQLSTATE。UseCursor(游标,光标)。________
7、__________________________________________8.1SQLinaProgrammingEnvironment建立和使用游标的步骤:游标说明DECLARE<游标名>[SCROLL]CURSORFORSELECT…打开游标OPEN<游标名>推进FETCH{NEXT
8、PRIOR
9、FIRST
10、LAST
11、RELATIVEn
12、ABSOLUTEn}FROM<游标名>INTO@变量名,…@@FETCH_STATUS=0表示正常。更新数据{UPDATE
13、DELETE}tableWHERECURRENTOF<游
14、标名>关闭游标CLOSE<游标名>__________________________________________________8.2模式中的存储过程存储过程(storedprocedure)与函数:在数据库中存储的一组SQL指令,有唯一命名,供应用程序调