DB2/400数据库编程

$1 Interfaces to UDB/400
1. Traditional system interface: 用CL命令创建数据库对象,DFU、SEU都可以修改数据
2. SQL:strsql、strqm、runsqlstm工具
使用runsqlstm工具执行一个sql脚本步骤:

3. iSeries Navigator
4. Query for iSeries: strqry或者wrkqry
如:查询表tbtest数据-runqry *N lyf1/tbtest

$2 Database Concept
1. Database files
A database file is one of several types of the system object type *FILE kept in the system.
2. Source file
A source file contains uncompiled programming code and input data needed to create some types of objects. A source file can contain source statements for such items as high-level language programs and data description specifications. A source file can be a source physical file, diskette file, tape file, or inline data file.
3. Physical file
A physical file is a database file that stores application data. Physical files contain one record format and one or more members. From the perspective of the SQL interface, physical files are identical to tables.
4. Logical file
A logical file is a database file that logically represents one or more physical files. From the perspective of the
SQL interface, logical files are identical to views and indexes.
5. Member
Members are different sets of data, each with the same format, within one database file. As a general rule, database files have only one member, the one created when the file is created. If a file contains more than one member, each member serves as a subset of the data in the file.
6. Record
A record is a group of related data within a file. From the perspective of the SQL interface, records are identical to rows.
命名规则:
数据库文件名、记录格式名、字段名长度只能小于等于10,如果使用CL命令创建数据库文件,长度超过10无法创建,如果使用SQL接口可以创建,但实际的数据库文件被重命名为长度为10的名字,在sql中使用两个名字都可以访问数据。

$3. 创建和定义数据库文件
共4个途径
1、IDDU
You can create a database file by using Interactive Data Definition Utility (IDDU)。
步骤:
--创建一个Dictionary(就是在一个lib)
--在Dictionary中创建field定义
--根据field创建Record Format
--根据RecordF创建数据库文件
2、OS/400 CL
首先用CRTPF、CRTLF、CRTSRCPF命令创建好数据库文件,然后用SEU或DFU描述文件中的数据规范(DDS)。
3、SQL
You can create and describe a database file (table) by using Structured Query Language (SQL) statements.
4、iSeries Navigator

$4. 创建源文件(Source File)
1、Why source files are used
如果在创建对象时,命令不能提供足够的信息,就需要创建源文件。
例如:创建一个CL程序,必须有source statement源文件,创建逻辑文件,必须有一个含DDS信息的源文件。
一般情况,如果依赖源文件创建一个对象,源文件中的成员名称和所要创建的对象名称相同。
创建下面对象,源文件是必须的:
* High-level language programs
* Control language programs
* Logical files
* Intersystem communications function (ICF) files
* Commands
创建下面对象,源文件可能被用到,但不是必须的:
* Physical files
* Display files
* Printer files
* Translate tables
2、Creating a source file using CRTSRCPF
CRTSRCPF FILE(QGPL/lyfsource) TEXT(’Source file’)
3、IBM-supplied source files
系统为每种类型对象创建提供了缺省的源文件,如CRTCLPGM命令使用QCLSRC文件名作为缺省值。

$4. 管理数据库文件
1、拷贝文件CPYF
1)将tbfrom表中的数据追加到tbto表格中
CPYF FROMFILE(LYF1/TBFROM) TOFILE(LYF2/TBTO) MBROPT(*ADD)
MBROPT提供三种模式:*ADD,*REPLACE,*UPDADD,并且提供from…to的记录拷贝功能
2)复制一份tbfrom表格并且含数据
CPYF FROMFILE(LYF1/TBFROM) TOFILE(LYF2/TBFROM2) CRTFILE(*YES)
2、移动文件MOVOBJ
MOVOBJ OBJ(LYF1/TBFROM) OBJTYPE(*FILE) TOLIB(LYF2)
3、删除文件
DLTF (LYF1/TBFROM)
4、查看文件属性
#查看数据库文件大小
wrkobj obj(LYF2/TBFROM2)
Storage information:
Size . . . . . . . . . . . . . . . : 53248
Offline size . . . . . . . . . . . : 0

#查看数据库文件的逻辑属性,如:约束、触发器
dspfd file(lyf1/tb2007) type(*cst/*trg/*all)
如果没有约束和触发器,就不会显示这些信息。

#查看数据库文件的物理属性,如:物理存储、字符集、权限、操作统计
wrkf file(lyf2/tbfrom2) #查看数据库文件的物理属性,如:物理存储、字符集、权限、操作统计
查看下面属性
DBCS capable . . . . . . . . . . . . . . . : No
Maximum members . . . . . . . . . . . . . . : MAXMBRS *NOMAX
Number of constraints . . . . . . . . . . . : 0
Number of triggers . . . . . . . . . . . . : 0
Number of members . . . . . . . . . . . . . : 2
Member size . . . . . . . . . . . . . . . . : SIZE *NOMAX
Allocate storage . . . . . . . . . . . . . : ALLOCATE *NO
Contiguous storage . . . . . . . . . . . . : CONTIG *NO
Preferred storage unit . . . . . . . . . . : UNIT *ANY
Records to force a write . . . . . . . . . : FRCRATIO *NONE
Maximum file wait time . . . . . . . . . . : WAITFILE *IMMED
Maximum record wait time . . . . . . . . . : WAITRCD 60
Max % deleted records allowed . . . . . . . : DLTPCT *NONE
Reuse deleted records . . . . . . . . . . . : REUSEDLT *YES
字符集:
Coded character set identifier . . . . . . : CCSID 1141
操作权限:
Allow read operation . . . . . . . . . . . : Yes
Allow write operation . . . . . . . . . . . : Yes
Allow update operation . . . . . . . . . . : ALWUPD *YES
Allow delete operation . . . . . . . . . . : ALWDLT *YES
RF检查选项:
Record format level check . . . . . . . . . : LVLCHK *YES
访问路径:
Access path . . . . . . . . . . . . . . . . : Arrival
Access path size . . . . . . . . . . . . . : ACCPTHSIZ *MAX1TB
Maximum record length . . . . . . . . . . . : 12
File is currently journaled . . . . . . . . : No
Access Path Description
Access path . . . . . . . . . . . . . . . . : Arrival
Sort Sequence . . . . . . . . . . . . . . . : SRTSEQ *HEX
Language identifier . . . . . . . . . . . . : LANGID ENG
Member Description
Member . . . . . . . . . . . . . . . . . . : MBR TBFROM
Member level identifier . . . . . . . . . : 1070724085102
Member creation date . . . . . . . . . . : 24.07.07
Text ‘description’ . . . . . . . . . . . : TEXT
Expiration date for member . . . . . . . : EXPDATE *NONE
Member size . . . . . . . . . . . . . . . : SIZE *NOMAX
Current number of records . . . . . . . . : 4
Number of deleted records . . . . . . . . : 1
Allocate storage . . . . . . . . . . . . : ALLOCATE *NO
Contiguous storage . . . . . . . . . . . : CONTIG *NO
Preferred storage unit . . . . . . . . . : UNIT *ANY
Records to force a write . . . . . . . . : FRCRATIO *NONE
Share open data path . . . . . . . . . . : SHARE *NO
Max % deleted records allowed . . . . . . : DLTPCT *NONE
数据操作统计信息:
Data Space Activity Statistics . . . . . :
Data space size in bytes . . . . . . . : 12288
Physical file open accesses . . . . . . : 8
Physical file close accesses . . . . . : 7
Write operations . . . . . . . . . . . : 5
Update operations . . . . . . . . . . . :
Delete operations . . . . . . . . . . . : 1
Logical Reads . . . . . . . . . . . . . : 21
Physical Reads . . . . . . . . . . . . : 2
Clear operations . . . . . . . . . . . :
Data space copy operations . . . . . . :
Reorganize operations . . . . . . . . . :
Access paths builds/rebuilds . . . . . :
Records rejected by key selection . . . :
Records rejected by non-key selection . : 4
Records rejected by group-by selection. :
Access Path Activity Statistics . . . . . :
Access path logical reads . . . . . . . :
Access path physical reads . . . . . . :
Implicit access path sharing . . . . . : No
Last change date/time . . . . . . . . . . : 24.07.07 10:16:28
Last save date/time . . . . . . . . . . . :
Last restore date/time . . . . . . . . . :
Last used date . . . . . . . . . . . . . : 24.07.07
Days used count . . . . . . . . . . . . . : 1
Reset date . . . . . . . . . . . . . . :
Member . . . . . . . . . . . . . . . . . . : MBR FEB
Member level identifier . . . . . . . . . : 1070724095738
Member creation date . . . . . . . . . . : 24.07.07
Text ‘description’ . . . . . . . . . . . : TEXT
Expiration date for member . . . . . . . : EXPDATE *NONE
Member size . . . . . . . . . . . . . . . : SIZE *NOMAX
Current number of records . . . . . . . . : 0
Number of deleted records . . . . . . . . : 0
Allocate storage . . . . . . . . . . . . : ALLOCATE *NO
Contiguous storage . . . . . . . . . . . : CONTIG *NO
Preferred storage unit . . . . . . . . . : UNIT *ANY
Records to force a write . . . . . . . . : FRCRATIO *NONE
Share open data path . . . . . . . . . . : SHARE *NO
Max % deleted records allowed . . . . . . : DLTPCT *NONE
Data Space Activity Statistics . . . . . :
Data space size in bytes . . . . . . . : 12288
Physical file open accesses . . . . . . : 1
Physical file close accesses . . . . . : 1
Write operations . . . . . . . . . . . :
Update operations . . . . . . . . . . . :
Delete operations . . . . . . . . . . . :
Logical Reads . . . . . . . . . . . . . :
Physical Reads . . . . . . . . . . . . :
Clear operations . . . . . . . . . . . :
Data space copy operations . . . . . . :
Reorganize operations . . . . . . . . . :
Access paths builds/rebuilds . . . . . :
Records rejected by key selection . . . :
Records rejected by non-key selection . :
Records rejected by group-by selection. :
Access Path Activity Statistics . . . . . :
Access path logical reads . . . . . . . :
Access path physical reads . . . . . . :
Implicit access path sharing . . . . . : No
Last change date/time . . . . . . . . . . : 24.07.07 09:57:38
Last save date/time . . . . . . . . . . . :
Last restore date/time . . . . . . . . . :
Last used date . . . . . . . . . . . . . : 24.07.07
Days used count . . . . . . . . . . . . . : 1
Reset date . . . . . . . . . . . . . . :
Record Format List
Record Format Level
Format Fields Length Identifier
TBFROM 1 12 2DA374E705DE7
Text . . . . . . . . . . . . . . . . . . . :
Total number of formats . . . . . . . . . . : 1
Total number of fields . . . . . . . . . . . : 1
Total record length . . . . . . . . . . . . : 12
Member List
Source Creation Last Change Deleted
Member Size Type Date Date Time Records Records
FEB 12288 24.07.07 24.07.07 09:57:38 0 0
Text:
TBFROM 12288 24.07.07 24.07.07 10:16:28 4 1
Text:
Total number of members . . . . . . . . . : 2
Total number of members not available . . : 0
Total records . . . . . . . . . . . . . . : 4
Total deleted records . . . . . . . . . . : 1
Total of member sizes . . . . . . . . . . : 24576

$5. 管理数据库成员
1、增加成员
使用CRTPF、CRTLF缺省增加一个与文件名相同的成员,当然指定MBR参数为*NONE时就不产生成员,CRTSRCPF命令缺省不创建成员;
如果PF或LF已创建好,使用ADDPFM、ADDLFM添加成员:
CHGPF FILE(LYF2/TBFROM2) MAXMBRS(*NOMAX) #修改成员数量不受限制
ADDPFM FILE(LYF2/TBFROM2) MBR(JAN)
2、修改成员属性
使用CHGPFM、CHGLFM命令修改,SRCTYPE, EXPDATE (the member’s expiration date), SHARE (whether the member can be shared within a job), and TEXT (the text description of the member)属性。
成员的最大大小需要用CHGPF、CHGLF修改
3、修改成员名称
RNMM FILE(LYF2/TBFROM2) MBR(JAN) NEWMBR(FEB)
4、删除成员
rmvm FILE(LYF2/TBFROM2) MBR(FEB)
5、清除成员中的数据
clrPFM FILE(LYF2/TBFROM2) MBR(FEB)
6、使用RGZPFM命令重组物理文件(也可以在sql中使用reorg table命令)
如果文件到达序列组织数据,通过使用关键词序列重组物理文件,使数据物理位置按照key序列存放;
重整物理文件,可以压缩被删除的记录,它的相对记录号会重新编制
RGZPFM file(lyf2/tbfrom2)
7、显示成员中的记录
DSPPFM FILE(LYF2/TBFROM2) MBR(FEB)

$6. 查看文件属性
1、显示数据库文件特性(表格属性)
dspfd file(lyf1/tbfrom)
wrkf file(lyf1/tbfrom)
2、显示字段描述(表格字段定义)
dspffd file(lyf1/tbfrom)
3、显示文件的依赖关系
dspdbr file(lyf1/tbfrom)
4、显示系统交叉引用文件
The system manages eight database files that contain:
* Basic database file attribute information (QSYS/QADBXREF)
* Cross-reference information (QSYS/QADBFDEP) about all the database files on the system (except those database files that are in the QTEMP library)
* Database file field information (QSYS/QADBIFLD)
* Database file key field information (QSYS/QADBKFLD)
* Referential constraint file information (QSYS/QADBFCST)
* Referential constraint field information (QSYS/QADBCCST)
* SQL package information (QSYS/QADBPKG)
* Remote database directory information (QSYS/QADBXRDBD)

$7. 使用源文件
1、显示一个对象(假设由源文件创建的)的源文件,使用detail选项即可
DSPOBJD OBJ(LYF1/VW001) OBJTYPE(*ALL) DETAIL(*SERVICE)

$1.1 基本操作
Starting interactive SQL:STRSQL
Starting Query Manager:STRQM
(1)INSERT数据
如果定义DataLink列缺省值,可以用函数DLVALUE('’,'URL’,'’).
如果想是插入数据为追加模式,使用CHGPF命令修改表格文件的Reuse Deleted Records属性为*NO.
插入数据的顺序不能保证检索的缺省顺序.
如果指定COMMIT(*ALL), COMMIT(*CS), COMMIT(*CHG), or COMMIT(*RR)(交换SQL会话的属性),insert语句执行失败,已经插入的数据将回滚
如果指定COMMIT(*NONE),insert语句执行失败,已经插入的数据将提交
NOTES:
修改SQL会话的属性:在Enter SQL Statements画面点击F13 Services,选择修改会话属性菜单即可,在该窗口可以修改select输出方式、提交控制方式、日期格式及分隔符、时间格式及分隔符、数据预取功 能、哪种命名规范、排序方式和语言ID
如果命名规范采用SQL,查询语句写法selec * from lyf1.tbtest
如果命名规范采用SYS,查询语句写法selec * from lyf1/tbtest
insert into lyf1/tb2007(c1,c2) values(1,’a')在strsql下执行失败,原因是数值之间用逗号隔开后还需加一个空格,否则在STRSQL下执行报错,如果数据都是字符串或 数字,不需要加,如果数据类型是混合的,数据需要用逗号和空格隔开。

(2)UPDATE数据
如果指定COMMIT(*ALL), COMMIT(*CS), COMMIT(*CHG), or COMMIT(*RR)(交换SQL会话的属性),update语句执行失败,已经修改的数据将回滚
如果指定COMMIT(*NONE),update语句执行失败,已经修改的数据将提交
特殊写法:
UPDATE EMPLOYEE SET (WORKDEPT, PHONENO, JOB)= (’D11’, ’7213’, ’DESIGNER’) WHERE EMPNO = ’000270’ #几个字段同时改
UPDATE CL_SCHED SET ROW =(SELECT * FROM MYCOPY WHERE CL_SCHED.CLASS_CODE = MYCOPY.CLASS_CODE) #块修改

(3)DELETE数据
如果指定COMMIT(*ALL), COMMIT(*CS), COMMIT(*CHG), or COMMIT(*RR)(交换SQL会话的属性),delete语句执行失败,已经删除的数据将回滚
如果指定COMMIT(*NONE),delete语句执行失败,已经删除的数据将提交
使用DELETE语句批量删除的时候,建议使用系统命令终止日志记录:ENDJRNPF

(4)SELECT数据
db2/400中没有sysibm.sysdummy1对象,如果要查询某个特定寄存器或常量或函数,只需要找任意一张表格查询即可
select 1+1 from tbtest
select user from tbtest
select CURRENT_DATE from tbtest
select CURRENT_SERVER from tbtest
数据库字典表放在QSYS2库中,譬如:
select table_name from qsys2/systables(syscolumns)
select table_name from schema_name/systables(syscolumns)

(5)创建别名
如果表文件有多个成员,为了访问某个特定的成员,可以为这个成员建立别名
CREATE ALIAS lyf1.MBR2_tbtest FOR lyf1.tbtest(MBR2)

$1.2 SQL中的特定寄存器:
CURRENT DATE=CURRENT_DATE:The current date.
CURRENT TIME=CURRENT_TIME:The current time.
CURRENT TIMESTAMP=CURRENT_TIMESTAMP:The current date and time in timestamp format.
CURRENT TIMEZONE=CURRENT_TIMEZONE:A duration of time that links local time to Universal Coordinated Time (UTC) using the formula:local time - CURRENT TIMEZONE = UTC It is taken from the system value QUTCOFFSET.
CURRENT SERVER=CURRENT_SERVER:The name of the relational database as contained in the relational database directory table in the relational database directory.
USER: The run-time authorization identifier (user profile) of the job.
CURRENT PATH=CURRENT_PATH=CURRENT FUNCTION PATH:The SQL path used to resolve unqualified data type names, procedure names, and function names.

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源简介 第 1章 – DB2 Express-C是什么?..........................................................................................13 1.1免费开发、部署和分发… 无限制!...............................................................................13 1.2用户帮助和技术支持.....................................................................................................14 1.3 DB2服务器..................................................................................................................14 1.4 DB2客户端和驱动........................................................................................................14 1.5 应用程序开发的自由性.................................................................................................15 1.6 DB2 版本号与 DB2 版本分类........................................................................................16 1.7升级到其它的 DB2版本................................................................................................16 1.8 DB2 Express-C的维护.................................................................................................16 1.9相关免费软件................................................................................................................17 1.9.1 IBM数据工作室(Data Studio)...........................................................................17 1.9.2 DB2 Net Search Extender .....................................................................................17 1.9.3 Starter Toolkit for DB2 on Rails.............................................................................17 1.9.4 Web 2.0 Starter Toolkit for DB2 ............................................................................17 1.9.5 WebSphere Application Server – Community Edition............................................18 第 2章 – DB2相关特性和产品................................................................................................19 2.1 DB2 Express-C订购中包含的功能...............................................................................22 2.1.1 Fix packs补丁包...................................................................................................22 2.1.2高可用性灾难恢复(HADR) ................................................................................22 2.1.3数据复制(Data Replication)...............................................................................22 2.2 DB2 Express-C所不具备的功能...................................................................................23 2.2.1数据库分区............................................................................................................23 2.2.2连接集中器(Connection Concentrator ).............................................................23 2.2.3 Geodetic Extender ................................................................................................23 2.2.4工作负载管理(Workload Management, WLM) .......................................................24 2.3 DB2相关收费产品........................................................................................................24 2.3.1 DB2连接(DB2 Connect)...................................................................................24 2.3.2 WebSphere Federation Server..............................................................................24 2.3.3 WebSphere Replication Server .............................................................................25 第 3章 – 安装 DB2..................................................................................................................27 3.1安装前提条件................................................................................................................27 3.2操作系统中的安装权限.................................................................................................27 3.3安装向导.......................................................................................................................27 3.4自动安装.......................................................................................................................31 实验 #1 安装DB2 Express-C,创建 SAMPLE数据库........................................................32 第 4章 – DB2的应用环境.......................................................................................................35 实验 #2 - 创建一个新的数据库............................................................................................43 4.1 DB2配置......................................................................................................................44 4.1.1 环境变量................................................................................................................44 4.1.2 数据库管理器配置文件(dbm cfg) ...........................................................................44 4.1.3 数据库配置文件(db cfg)....................................................................................46 4.1.4 DB2 概要文件注册表.............................................................................................47 4.2 DB2管理服务器...........................................................................................................48 实验 #3 – 实例、数据库和配置管理....................................................................................49 第 5章 – DB2工具..................................................................................................................51 5.1控制中心(Control Center).........................................................................................52 5.2命令编辑器(Command Editor) .................................................................................55 5.3 SQL帮助向导(SQL Assist Wizard ).........................................................................57 5.4 显示SQL按钮..............................................................................................................58 实验 #4 使用脚本填充EXPRESS数据库...........................................................................59 5.5 脚本..............................................................................................................................60 5.5.1 SQL脚本...............................................................................................................60 5.5.2操作系统(shell)脚本..........................................................................................61 实验 #5 为EXPRESS数据库创建一个安装脚本.................................................................62 5.6任务中心(Task Center )...........................................................................................65 5.6.1工具目录(Tools Catalog)数据库........................................................................65 5.7 日志(Journal)...........................................................................................................66 5.8运行状况监视器(Health Monitor ).............................................................................67 5.8.1运行状况中心(Health Center )...........................................................................68 PART II – DB2 Express-C 数据库管......................................................................................71 第 6章 – DB2体系结构...........................................................................................................73 6.1 DB2进程模型...............................................................................................................73 6.2 DB2内存模型...............................................................................................................74 6.3 DB2存储模型...............................................................................................................75 6.3.1数据页和扩展数据块..............................................................................................75 6.3.2缓冲池...................................................................................................................76 6.3.3表空间...................................................................................................................77 第 7章 – DB2 客户端的连接....................................................................................................81 7.1 DB2 目录......................................................................................................................81 7.2 配置助手(Configuration Assistant )..........................................................................82 7.2.1服务器端的安装要求..............................................................................................82 7.2.2 Setup required at the client 客户端的安装要求......................................................84 7.2.3建立客户端与服务器端概要文件............................................................................87 实验 #6 使用配置助手........................................................................................................90 第 8章 – 数据库对象...............................................................................................................93 8.1 模式..............................................................................................................................93 8.2表.................................................................................................................................93 8.2.1数据类型................................................................................................................93 8.2.2标识列...................................................................................................................96 8.2.3序列对象................................................................................................................96 8.2.4系统目录表............................................................................................................97 8.2.5已声明临时表.........................................................................................................97 实验 #7 创建一个数据表.....................................................................................................99 8.3视图............................................................................................................................101 8.4索引............................................................................................................................101 8.4.1 Design Advisor ....................................................................................................101 8.5参照完整性.................................................................................................................102 第 9章 – 数据迁移工具..........................................................................................................105 9.1 导出(EXPORT)工具...............................................................................................106 9.2 导入(IMPORT)工具................................................................................................106 9.3 使用 LOAD来导入......................................................................................................107 9.4 db2move 工具...........................................................................................................108 9.5 db2look 工具..............................................................................................................109 实验 #8 导出EXPRESS数据库的DDL............................................................................111 第 10章 – 数据库安全...........................................................................................................115 10.1 认证..........................................................................................................................116 10.2 授权..........................................................................................................................116 10.3 DBADM权限............................................................................................................118 10.4 PUBLIC 组...............................................................................................................119 10.5 GRANT和REVOKE语句 ........................................................................................119 10.6 查看授权和特权........................................................................................................119 10.7 关于组特权...............................................................................................................121 实验 #9 授予和撤销用户的权限........................................................................................122 第 11章 – 备份和恢复...........................................................................................................125 11.1 数据库的日志记录....................................................................................................125 11.2 日志的类型...............................................................................................................126 11.3 日志记录的类型.......................................................................................................126 11.3.1 循环日志记录 ....................................................................................................126 11.3.2 档案日志记录和日志保留...................................................................................127 11.4 从控制中心进行数据库日志记录...............................................................................127 11.5 日志记录的参数........................................................................................................129 11.6 数据库备份...............................................................................................................129 实验 #10 – 安排一个备份计划..........................................................................................131 11.7 数据库恢复...............................................................................................................133 11.7.1 恢复类型............................................................................................................133 11.7.2 数据库恢复........................................................................................................133 11.8 其他关于备份和恢复的操作......................................................................................134 第 12章 – 维护任务...............................................................................................................135 12.1 重组(REORG)、运行统计(RUNSTATS)、重绑定(REBIND).......................135 12.1.1重组(REORG)命令........................................................................................135 12.1.2运行统计(RUNSTATS)命令 ..........................................................................136 12.1.3 绑定/重新绑定.................................................................................................136 12.1.4 在控制中心执行维护工作...................................................................................137 12.2 维护方式...................................................................................................................139 实验#11 – 配置自动维护.................................................................................................141 第 13章 – 并行与锁定...........................................................................................................143 13.1 事务(Transactions)..............................................................................................143 13.2 并行(Concurrency) ..............................................................................................143 13.3无并行控制导致的问题 .............................................................................................144 13.3.1丢失更新(Lost update)..................................................................................145 13.3.2未落实的读(Uncommitted read)....................................................................145 13.3.3不可重复读(Non-repeatable read).................................................................146 13.3.4幻象(Phantom read)......................................................................................146 13.4隔离级别(Isolation Levels)...................................................................................147 13.4.1未落实的读........................................................................................................147 13.4.2游标稳定性........................................................................................................147 13.4.3读稳定性............................................................................................................148 13.4.4可重复读............................................................................................................148 13.4.5隔离级别对比.....................................................................................................148 13.4.6设定隔离级别.....................................................................................................149 13.5锁定升级...................................................................................................................150 13.6锁定监视...................................................................................................................151 13.7锁定等待...................................................................................................................151 13.8死锁的引发与侦测.....................................................................................................152 13.9并行与锁定的最佳实践:..........................................................................................153 PART III – DB2 Express-C应用程序开发............................................................................155 第 14章 –SQL PL 存储过程..................................................................................................157 14.1 IBM数据工作室(Data Studio)..............................................................................158 14.1.2在Data Studio中创建一个存储过程..................................................................159 14.2 SQL PL 存储过程基础..............................................................................................161 14.2.1存储过程的结构.................................................................................................161 14.2.2 可选的存储过程属性..........................................................................................162 14.2.3参数...................................................................................................................162 14.2.4 SQL PL存储过程中的注释................................................................................163 14.2.5 复合语句............................................................................................................163 14.2.6 变量声明............................................................................................................163 14.2.7 赋值语句............................................................................................................164 14.3 游标..........................................................................................................................164 14.4 流控制......................................................................................................................164 14.5 调用存储过程 ...........................................................................................................165 14.6 错误和情况处理器....................................................................................................166 14.7 动态SQL..................................................................................................................168 第 15章 – 直接插入 SQL 过程语言、触发器、用户定义函数(UDF)..................................169 15.1直接插入SQL PL .....................................................................................................169 15.2 触发器(Trigger)....................................................................................................170 15.2.1 触发器的类型 ....................................................................................................170 实验 #12 从控制中心创建一个触发器...............................................................................174 15.3 用户定义函数 (UDF).................................................................................................177 15.3.1 标量函数(Scalar function).............................................................................177 15.3.2 表函数(Table function)..................................................................................178 实验 #13 使用IBM Data Studio创建用户定义函数(UDF)............................................179 第 16章 – DB2 pureXML......................................................................................................181 16.1 在数据库中使用XML................................................................................................181 16.2 XML数据库..............................................................................................................182 16.2.1 启用 XML的数据库............................................................................................182 16.2.2 原生 XML数据库...............................................................................................182 16.3 DB2中的XML..........................................................................................................183 16.3.1 pureXML 技术优势............................................................................................184 16.3.2 XPath基础........................................................................................................185 16.3.3 XQuery的定义..................................................................................................188 16.3.4 插入 XML文档...................................................................................................189 16.3.5 查询 XML数据...................................................................................................191 16.3.6 使用 SQL/XML执行联合操作............................................................................196 16.3.7 使用 XQuery执行联合操作................................................................................196 16.3.8 更新与删除操作.................................................................................................197 16.3.9 XML 索引.........................................................................................................198 实验 #14 - SQL/XML 和 XQuery.......................................................................................200 第 17章 – 使用 Java、PHP和 Ruby进行数据库应用开发...................................................201 17.1 Java应用程序开发...................................................................................................201 17.1.1 JDBC类型 2驱动程序.......................................................................................201 17.1.2 JDBC类型 4驱动程序.......................................................................................202 17.2 PHP应用程序开发...................................................................................................203 17.2.1 DB2为PHP提供的连接选项.............................................................................203 17.2.2 Zend Core for IBM.............................................................................................204 17.3 Ruby on Rails应用程序开发.....................................................................................206 17.3.1 Startup Toolkit for DB2 on Rails ........................................................................206 附录 A — 排除故障...............................................................................................................207 A.1 查找错误代码的更多信息...........................................................................................207 A.2 SQLCODE与SQLSTATE .........................................................................................208 A.3 DB2 管理通知日志.....................................................................................................208 A.4 db2diag.log................................................................................................................209 A.5 CLI追踪.....................................................................................................................209 A.6 DB2缺陷与补丁.........................................................................................................209 参考资源 ...............................................................................................................................210 网站..................................................................................................................................210 书籍..................................................................................................................................211

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值