db2命令行(linux) 整理(更新中)

1.数据库实例的启动

首先要启动数据库的实例,即切换到db2inst1用户(注:db2inst1用户为当前数据库的实例),然后执行db2start启动数据库的实例
[root@localhost instance]# su - db2inst1
[db2inst1@localhost ~]$ db2start

SQL1063N  DB2START processing was successful.



2.数据库实例的关闭

首先在db2inst1用户下强制关闭实例上的所有应用程序,然后再关闭数据库实例
[db2inst1@localhost ~]$ db2 force application all
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.

[db2inst1@localhost ~]$ db2stop
SQL1064N  DB2STOP processing was successful.
[db2inst1@localhost ~]$


强制停止
[db2inst1@localhost DB2]$ db2stop force
SQL1064N  DB2STOP processing was successful.
[db2inst1@localhost DB2]$


3.显示所有的实例

[db2inst1@localhost ~]$ db2ilist
db2inst1
[db2inst1@localhost ~]$



4.显示当前的实例

[db2inst1@localhost ~]$ db2 get instance

 The current database manager instance is:  db2inst1



5.删除一个实例(注:需切换到root用户权限下)

[root@localhost ~]# cd /opt/ibm/db2/V9.7/instance
[root@localhost instance]# pwd
/opt/ibm/db2/V9.7/instance
[root@localhost instance]# ./db2idrop db2inst1
DBI1070I  Program db2idrop completed successfully.


6.列出当前实例中有哪些数据库

[root@localhost instance]# su - db2inst1
[db2inst1@localhost ~]$ db2 list db directory
SQL1031N  The database directory cannot be found on the indicated file system.

SQLSTATE=58031
[db2inst1@localhost ~]$
注:上面信息说明实例中没有数据库

我的--

 Database alias                       = XMETA
 Database name                        = XMETA
 Local database directory             = /opt/IBM/InformationServer/Repos/xmeta
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 2 entry:

 Database alias                       = QS
 Database name                        = QS
 Local database directory             = /home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 3 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = /home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

db2inst1@infosrvr:~> 


7.创建数据库

[root@localhost instance]# su - db2inst1
[db2inst1@localhost ~]$ db2 create database test
SQL1032N  No start database manager command was issued.  SQLSTATE=57019
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$ db2start
SQL5043N  Support for one or more communications protocols failed to start successfully. However, core database manager functionality started successfully.
[db2inst1@localhost ~]$ db2 create database test
DB20000I  The CREATE DATABASE command completed successfully.
[db2inst1@localhost ~]$ db2 list db directory

System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = TEST
 Database name                        = TEST
 Local database directory             = /home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

[db2inst1@localhost ~]$
注:上面通过创建一个test的数据库,并说明了创建数据库时,要先启动数据库,然后创建数据库test成功后并列出了当前实例中的所有数据库,只存在数据库test


使用UTF-8编码  
db2 create database test on '/home/db2inst1' using codeset UTF-8 territory CN
on '/home/db2inst1' 表示数据库路径
一般情况下'/home/db2inst1'为默认数据库路径


8.连接数据库

[db2inst1@localhost ~]$ db2 connect to test

   Database Connection Information

 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

[db2inst1@localhost ~]$

注:用密码情况下格式[db2inst1@localhost ~]$ db2 connect to test user username using password

db2 connect to user using 



9.列出当前实例中所有激活的数据库

[root@localhost ~]# su - db2inst1

[db2inst1@localhost ~]$ db2start
SQL1026N  The database manager is already active.
[db2inst1@localhost ~]$ db2 list active databases
SQL1611W  No data was returned by Database System Monitor.
[db2inst1@localhost ~]$ db2 connect to test

   Database Connection Information

 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

[db2inst1@localhost ~]$ db2 list active databases

                           Active Databases

Database name                              = TEST
Applications connected currently           = 1
Database path                              = /home/db2inst1/db2inst1/NODE0000/SQL00001/

[db2inst1@localhost ~]$ 
注:可以看出查看当前激活的数据库为已经启动后连接的数据库


10.查看表的空间

[db2inst1@localhost ~]$ db2 list tablespaces [ show detail ]

   


[db2inst1@localhost ~]$
注: show detail为可选项,显示更详细信息

或者 db2pd -tablespaces -db 数据库名
[db2inst1@localhost ~]$ db2pd -tablespaces -db test

11.列出数据库中所有用户表

[db2inst1@localhost ~]$ db2 connect to test

   Database Connection Information

 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

[db2inst1@localhost ~]$  db2 list tables

Table/View                      Schema          Type  Creation time            
------------------------------- --------------- ----- --------------------------

  0 record(s) selected.

[db2inst1@localhost ~]$

注:上面信息说明数据库test中还没有表

 

12.在数据库test中创建表student 

[db2inst1@localhost ~]$ db2 connect to test

   Database Connection Information

 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

[db2inst1@localhost ~]$ db2 "create table student (id int,fname varchar(30),age int)"
DB20000I  The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 list tables

Table/View                      Schema          Type  Creation time            
------------------------------- --------------- ----- --------------------------
STUDENT                         DB2INST1        T     2012-08-06-14.38.33.456768

  1 record(s) selected.

[db2inst1@localhost ~]$

 

13.向表student中添加数据信息

[db2inst1@localhost ~]$ db2 "insert into student values (1,'Tom',22)"
DB20000I  The SQL command completed successfully.

14.显示表student所有的信息

[db2inst1@localhost ~]$ db2 "select * from student"

ID          FNAME                          AGE       
----------- ------------------------------ -----------
          1 Tom                                     22
          2 Jack                                    21
          3 Sunrier                                 25

  3 record(s) selected.

[db2inst1@localhost ~]$



16.查看表student结构

[db2inst1@localhost ~]$ db2 describe table student



17.创建一个新表(如people)与数据库中某个表(如student)结构相同

[db2inst1@localhost ~]$ db2 create table people like student
DB20000I  The SQL command completed successfully.


18.两个结构相同的表,将原来数据库中某个表(如student)的数据导入与它相同结构的新表(如people)中

[db2inst1@localhost ~]$ db2 "insert into people select * from student"
DB20000I  The SQL command completed successfully.


19.修改一个表的字段类型(如表people中的fname字段把varchar(30)改为varchar(28))

格式:db2 "alter table alter column set data type "
tablename:表名
columnname:字段名
datatype:字段类型

注:
一般更改字段类型是有操作限制的. 将字段改为比之前类型长度大的可以;如果要改小,必须先drop掉原来的column,然后再重新添加.
虽然我上面的执行成功了,可能是因为我用的官方免费版本的,如果遇到把长度大的改为小的无法执行,先用drop,再重新添加



20.向一个表添加字段(如向表people中添加备注信息字段notes;向表people中添加分数字段score)

格式:db2 "alter table add "

[db2inst1@localhost ~]$ db2 "alter table people add notes varchar(100)"
DB20000I  The SQL command completed successfully.


21.删除表中的某个字段(如删除表people中的字段score)

格式:db2 "alter table drop column "

[db2inst1@localhost ~]$ db2 "alter table people drop column score"
DB20000I  The SQL command completed successfully.


22.给表中添加带默认值的字段(如向表people中添加分数字段score,默认设置为100)

格式:db2 "alter table add column not null with default "

[db2inst1@localhost ~]$ db2 "alter table people add column score interger not null with default 90"
DB20000I  The SQL command completed successfully.


例1.向表people中添加地址字段address默认设置为shanghai
db2 "alter table people add column address varchar(30) not null with default 'ShangHai'"

例2.将表people中地址字段address默认设置改为当前时间
db2 "alter table people alter column address set default current date"
格式:db2 "alter table alter column set default "


23.列出数据库中用户表

[db2inst1@localhost ~]$ db2 list tables for user


24.列出数据库中所有系统表

[db2inst1@localhost ~]$ db2 list tables for system


25.列出数据库中所有表

[db2inst1@localhost ~]$ db2 list tables for all


26.列出数据库中特定用户表 

[db2inst1@localhost ~]$ db2 list tables for schema db2inst1

Table/View                      Schema          Type  Creation time            
------------------------------- --------------- ----- --------------------------
STUDENT                         DB2INST1        T     2012-08-06-15.26.17.189538


27.删除表中的数据 :

[db2inst1@localhost ~]$ db2 delete from student where id=3 
DB20000I  The SQL command completed successfully.


28.删除一个数据库中的某个表 

[db2inst1@localhost ~]$ db2 drop table student


29.删除一个数据库test

[db2inst1@localhost ~]$ db2 drop db test 
SQL1035N  The database is currently in use.  SQLSTATE=57019
SQL1025N  The database manager was not stopped because databases are still active.
[db2inst1@localhost ~]$ db2 connect reset
DB20000I  The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 drop db test 
DB20000I  The DROP DATABASE command completed successfully.


30.显示当前数据库连接有哪些应用程序

[db2inst1@localhost DB2]$ db2 list application
SQL1611W  No data was returned by Database System Monitor.
[db2inst1@localhost DB2]$ db2 connect to test

   Database Connection Information

 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

[db2inst1@localhost DB2]$ db2 list application

Auth Id  Application    Appl.      Application Id                                                 DB       # of
         Name           Handle                                                                    Name    Agents
-------- -------------- ---------- -------------------------------------------------------------- -------- -----
DB2INST1 db2bp          35         *LOCAL.db2inst1.120807014245                                   TEST     1   

[db2inst1@localhost DB2]$



31.查看DB2全部受支持的注册表变量列表

[db2inst1@localhost DB2]$ db2set -lr


32.更改DB2 UDB注册表变量的值

db2set registry_variable_name=new_value
[db2inst1@localhost ~]$ db2set DB2COMM=TCPIP


33.查看在服务器上已经设置的所有DB2概要文件注册表

[db2inst1@localhost DB2]$ db2set -all
[i] DB2PROCESSORS=0
[i] DB2COMM=TCPIP
[i] DB2AUTOSTART=YES
[g] DB2SYSTEM=localhost.localdomain
[g] DB2INSTDEF=db2inst1
[g] DB2ADMINSERVER=db2dasusr1
[db2inst1@localhost DB2]$


34.导出表中的数据

以DEL格式导出
db2 "export to teacher.txt of del select * from teacher"
db2 "export to teacher_bak.txt of del modified by coldel| select * from teacher"
[db2inst1@localhost ~]$ ls
db2inst1  sqllib  Sunrier  teacher.sql  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001 
[db2inst1@localhost ~]$ db2 "export to teacher.txt of del select * from teacher"
SQL3104N  The Export utility is beginning to export data to file 
"teacher.txt".

SQL3105N  The Export utility has finished exporting "2" rows.


Number of rows exported: 2

[db2inst1@localhost ~]$ ls
db2inst1  sqllib  Sunrier  teacher.sql  teacher.txt  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001 
[db2inst1@localhost ~]$ cat teacher.txt 
1,"Lory","上海徐汇中学",19780806
2,"Sunrier","田林中学",19880627
[db2inst1@localhost ~]$


字段之间默认分隔符号为逗号,下面使用'|'分割
[db2inst1@localhost ~]$ db2 "export to teacher_bak.txt of del modified by coldel| select * from teacher"
SQL3104N  The Export utility is beginning to export data to file 
"teacher_bak.txt".

SQL3105N  The Export utility has finished exporting "2" rows.


Number of rows exported: 2

[db2inst1@localhost ~]$ ls
db2inst1  sqllib  Sunrier  teacher_bak.txt  teacher.sql  teacher.txt  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001
[db2inst1@localhost ~]$ cat teacher_bak.txt 
1|"Lory"|"上海徐汇中学"|19780806
2|"Sunrier"|"田林中学"|19880627
[db2inst1@localhost ~]$

 

以IXF格式导出  
[db2inst1@localhost ~]$ pwd
/home/db2inst1
[db2inst1@localhost ~]$ ls
db2inst1  sqllib  Sunrier  teacher_bak.txt  teacher.sql  teacher.txt  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001
[db2inst1@localhost ~]$ ls /home/db2inst1/Sunrier
TEST.0.db2inst1.NODE0000.CATN0000.20120817150317.001
[db2inst1@localhost ~]$ db2 "export to /home/db2inst1/Sunrier/teacher.ixf of ixf select * from teacher"
SQL3104N  The Export utility is beginning to export data to file 
"/home/db2inst1/Sunrier/teacher.ixf".

SQL3105N  The Export utility has finished exporting "4" rows.


Number of rows exported: 4

[db2inst1@localhost ~]$ ls /home/db2inst1/Sunrier
teacher.ixf  TEST.0.db2inst1.NODE0000.CATN0000.20120817150317.001
[db2inst1@localhost ~]$ 


如需要导出记录过程的message
[db2inst1@localhost ~]$ db2 "export to /home/db2inst1/Sunrier/teacher_bak.ixf of ixf messages /home/db2inst1/Sunrier/teacher.msg select * from teacher"

Number of rows exported: 4

[db2inst1@localhost ~]$ ls /home/db2inst1/Sunrier
teacher_bak.ixf  teacher.ixf  teacher.msg  TEST.0.db2inst1.NODE0000.CATN0000.20120817150317.001
[db2inst1@localhost ~]$ cat /home/db2inst1/Sunrier/teacher.msg 
SQL3104N  The Export utility is beginning to export data to file 
"/home/db2inst1/Sunrier/teacher_bak.ixf".

SQL3105N  The Export utility has finished exporting "4" rows.

[db2inst1@localhost ~]$




35.导入数据到一个表中

db2 "import from teacher.txt of del insert into teacher"
db2 "import from teacher_bak.txt of del modified by coldel| insert into teacher"
[db2inst1@localhost ~]$ ls
db2inst1  sqllib  Sunrier  teacher.sql  teacher.txt  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001 
[db2inst1@localhost ~]$ cat teacher.txt
3,"Jerry","上海徐汇中学",19710306
4,"Tim","田林中学",19820627
[db2inst1@localhost ~]$ db2 "select * from teacher"

ID          FNAME                ADDRESS                                                                          BIRTH    
----------- -------------------- -------------------------------------------------------------------------------- ----------
          1 Lory                 上海徐汇中学                                                                     1978-08-06
          2 Sunrier              田林中学                                                                         1988-06-27

  2 record(s) selected.

[db2inst1@localhost ~]$ db2 "import from teacher.txt of del insert into teacher"
SQL3109N  The utility is beginning to load data from file "teacher.txt".

SQL3110N  The utility has completed processing.  "2" rows were read from the
input file.

SQL3221W  ...Begin COMMIT WORK. Input Record Count = "2".

SQL3222W  ...COMMIT of any database changes was successful.

SQL3149N  "2" rows were processed from the input file.  "2" rows were
successfully inserted into the table.  "0" rows were rejected.


Number of rows read         = 2
Number of rows skipped      = 0
Number of rows inserted     = 2
Number of rows updated      = 0
Number of rows rejected     = 0
Number of rows committed    = 2

[db2inst1@localhost ~]$ db2 "select * from teacher"

ID          FNAME                ADDRESS                                                                          BIRTH    
----------- -------------------- -------------------------------------------------------------------------------- ----------
          1 Lory                 上海徐汇中学                                                                     1978-08-06
          2 Sunrier              田林中学                                                                         1988-06-27
          3 Jerry                上海徐汇中学                                                                     1971-03-06
          4 Tim                  田林中学                                                                         1982-06-27

  4 record(s) selected.

[db2inst1@localhost ~]$

 

36.利用脚本创建表

格式:db2 -tvf scriptName.sql

teacher.sql为以下内容
----建立表teacher 
create table teacher 
(
  id integer not null ,
  fname varchar(20) not null,
  address varchar(80) default '上海',
  birth date,
  primary key(id)
); 
--建表结束

--以下为插入数据字段
insert into teacher values(1,'Lory','上海徐汇中学','1978-08-06');
insert into teacher values(2,'Sunrier','田林中学','1988-06-27');

[db2inst1@localhost ~]$ db2 list tables

Table/View                      Schema          Type  Creation time            
------------------------------- --------------- ----- --------------------------
PEOPLE                          DB2INST1        T     2012-08-16-15.13.49.396370
STUDENT                         DB2INST1        T     2012-08-06-15.26.17.189538

  2 record(s) selected.

[db2inst1@localhost ~]$ db2 -tvf teacher.sql 
create table teacher ( id integer not null , fname varchar(20) not null, address varchar(80) default '上海', birth date, primary key(id) )
DB20000I  The SQL command completed successfully.

insert into teacher values(1,'Lory','上海徐汇中学','1978-08-06')
DB20000I  The SQL command completed successfully.

insert into teacher values(2,'Sunrier','田林中学','1988-06-27')
DB20000I  The SQL command completed successfully.

[db2inst1@localhost ~]$ db2 describe table teacher

                                Data type                     Column
Column name                     schema    Data type name      Length     Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ID                              SYSIBM    INTEGER                      4     0 No   
FNAME                           SYSIBM    VARCHAR                     20     0 No   
ADDRESS                         SYSIBM    VARCHAR                     80     0 Yes  
BIRTH                           SYSIBM    DATE                         4     0 Yes  

  4 record(s) selected.

[db2inst1@localhost ~]$ db2 "select * from teacher"

ID          FNAME                ADDRESS                                                                          BIRTH    
----------- -------------------- -------------------------------------------------------------------------------- ----------
          1 Lory                 上海徐汇中学                                                                     1978-08-06
          2 Sunrier              田林中学                                                                         1988-06-27

  2 record(s) selected.

[db2inst1@localhost ~]$


37.备份数据库(如防止表误操作)!脱机备份与恢复

格式:db2 backup db [ to ]
database name:表示数据库
to :表示为备份到的目录路径,为可选项,默认在当前目录下
[db2inst1@localhost ~]$ ls
db2inst1  sqllib  teacher.sql  
[db2inst1@localhost ~]$  db2 list db directory

 System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = TEST
 Database name                        = TEST
 Local database directory             = /home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =
 
[db2inst1@localhost ~]$ db2 backup db test

Backup successful. The timestamp for this backup image is : 20120817103306

[db2inst1@localhost ~]$ ls
db2inst1  sqllib  teacher.sql  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001
[db2inst1@localhost ~]$ db2 list active databases
SQL1611W  No data was returned by Database System Monitor.
[db2inst1@localhost ~]$

注:TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001即为备份的数据库节点文件;
   执行备份命令时,如果出现无法执行,则先断开数据库的连接再执行备份命令.
   我使用的免费版本的DB2数据库测试时,从上面可以看出没有断开也可以执行,但执行完,发现数据库
   处于断开状态了
如: db2 force application all  
强制关闭实例上的所有应用程序

[db2inst1@localhost ~]$ ls
db2inst1  sqllib  Sunrier  teacher_bak.txt  teacher.sql  teacher.txt  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001
[db2inst1@localhost ~]$ db2 backup db test to /home/db2inst1/Sunrier

Backup successful. The timestamp for this backup image is : 20120817150317
  
[db2inst1@localhost ~]$ ls
db2inst1  sqllib  Sunrier  teacher_bak.txt  teacher.sql  teacher.txt  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001
[db2inst1@localhost ~]$ cd Sunrier/
[db2inst1@localhost Sunrier]$ ls
TEST.0.db2inst1.NODE0000.CATN0000.20120817150317.001
[db2inst1@localhost Sunrier]$ 

说明:上面的方法为脱机备份(也称为离线备份或者冷备份),此方法必须断开所有与数据库连接的应用后才能进行,备份时数据库不能提供给用户使用. 


恢复数据库(如将一个表删除后,通过删除前的备份文件恢复)
格式:db2 restore db [ from

]
database name:表示恢复的数据库名
from :表示为从哪个目录路径下恢复,为可选项,默认在当前目录下
[db2inst1@localhost ~]$ db2 connect to test

   Database Connection Information

 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

[db2inst1@localhost ~]$ db2 list tables

Table/View                      Schema          Type  Creation time            
------------------------------- --------------- ----- --------------------------
PEOPLE                          DB2INST1        T     2012-08-16-15.13.49.396370
STUDENT                         DB2INST1        T     2012-08-06-15.26.17.189538
TEACHER                         DB2INST1        T     2012-08-17-10.18.18.245263

  3 record(s) selected.

[db2inst1@localhost ~]$ db2 "select * from teacher"

ID          FNAME                ADDRESS                                      BIRTH    
----------- -------------------- -------------------------------------------- ----------
          1 Lory                 上海徐汇中学                                 1978-08-06
          2 Sunrier              田林中学                                     1988-06-27
          3 Jerry                上海徐汇中学                                 1971-03-06
          4 Tim                  田林中学                                     1982-06-27

  4 record(s) selected.

[db2inst1@localhost ~]$ db2 drop table teacher
DB20000I  The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 list tables

Table/View                      Schema          Type  Creation time            
------------------------------- --------------- ----- --------------------------
PEOPLE                          DB2INST1        T     2012-08-16-15.13.49.396370
STUDENT                         DB2INST1        T     2012-08-06-15.26.17.189538

  2 record(s) selected.

[db2inst1@localhost ~]$ db2 connect reset
DB20000I  The SQL command completed successfully. 
[db2inst1@localhost Sunrier]$ ls /home/db2inst1/Sunrier
TEST.0.db2inst1.NODE0000.CATN0000.20120817150317.001
[db2inst1@localhost ~]$ db2 restore db test from /home/db2inst1/Sunrier
SQL2539W  Warning!  Restoring to an existing database that is the same as the 
backup image database.  The database files will be deleted.                            --(先删除后重建)
Do you want to continue ? (y/n) y
DB20000I  The RESTORE DATABASE command completed successfully.
[db2inst1@localhost ~]$ db2 list tables
SQL1024N  A database connection does not exist.  SQLSTATE=08003
[db2inst1@localhost ~]$ db2 connect to test

   Database Connection Information

 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

[db2inst1@localhost ~]$ db2 list tables

Table/View                      Schema          Type  Creation time            
------------------------------- --------------- ----- --------------------------
PEOPLE                          DB2INST1        T     2012-08-16-15.13.49.396370
STUDENT                         DB2INST1        T     2012-08-06-15.26.17.189538
TEACHER                         DB2INST1        T     2012-08-17-10.18.18.245263

  3 record(s) selected.

[db2inst1@localhost ~]$ db2 "select * from teacher"

ID          FNAME                ADDRESS                                      BIRTH    
----------- -------------------- -------------------------------------------- ----------
          1 Lory                 上海徐汇中学                                 1978-08-06
          2 Sunrier              田林中学                                     1988-06-27
          3 Jerry                上海徐汇中学                                 1971-03-06
          4 Tim                  田林中学                                     1982-06-27

  4 record(s) selected.

[db2inst1@localhost ~]$

注:如果想把恢复的数据库更改为新的数据库名,则格式如下 
  db2 restore db   [ from

into ]
例:db2 restore db test from /home/db2inst1/Sunrier into testdb
或者db2 restore db test from "/home/db2inst1/Sunrier" into testdb

 


38.在线备份与恢复(online)


(8.4.1) Log retain for recovery enabled (LOGRETAIN) = OFF 状态只能脱机备份
更改参数后可以进行在线全备份
[wzm@fedora ~]$ db2 update db cfg using LOGRETAIN ON
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W One or more of the parameters submitted for immediate modification
were not changed dynamically. For these configuration parameters, all
applications must disconnect from this database before the changes become
effective.
(8.4.2) 更改后的参数显示
wzm@fedora ~]$ db2 get db cfg | grep -i logretain
Log retain for recovery enabled (LOGRETAIN) = RECOVERY
First log archive method (LOGARCHMETH1) = LOGRETAIN
(8.4.3)在更改完参数后。连不上数据库,必须进行一次脱机全备份才能连上数据库
[wzm@fedora ~]$ db2 connect to wzmdb
SQL1116N A connection to or activation of database "WZMDB" cannot be made
because of BACKUP PENDING. SQLSTATE=57019

(8.4.4)进行一次全备份
[wzm@fedora ~]$ db2 backup db wzmdb to /home/db2backup/
Backup successful. The timestamp for this backup image is : 20060521124511
(8.4.5)连接数据库成功
[wzm@fedora ~]$ db2 connect to wzmdb
Database Connection Information
Database server = DB2/LINUX 8.2.0
SQL authorization ID = WZM
Local database alias = WZMDB
(8.4.6) 进行在线全备份
[wzm@fedora db2backup]$ db2 backup db wzmdb online to /home/db2backup/ include logs without prompting
Backup successful. The timestamp for this backup image is : 20060521124905
(8.4.7)备份恢复
[wzm@fedora db2backup]$ db2 restore db wzmdb taken at 20060521130338 into wzmdb_db logtarget /home/db2backup/logs/ without prompting
SQL2540W Restore is successful, however a warning "2580" was encountered
during Database Restore while processing in No Interrupt mode.
(8.4.8)连接数据库不成功,显示暂挂前滚状态。
[wzm@fedora db2backup]$ db2 connect to wzmdb_db
SQL1117N A connection to or activation of database "WZMDB_DB" cannot be made
because of ROLL-FORWARD PENDING. SQLSTATE=57019

(8.4.9)日志的恢复
[wzm@fedora db2backup]$ db2 "rollforward db wzmdb_db to end of logs and stop overflow log path (/home/db2backup/logs)"
Rollforward Status
Input database alias = wzmdb_db
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000001.LOG - S0000001.LOG
Last committed transaction = 2006-05-21-05.03.53.000000
DB20000I The ROLLFORWARD command completed successfully.

(8.9.10)数据库的连接成功
[wzm@fedora db2backup]$ db2 connect to wzmdb_db
Database Connection Information
Database server = DB2/LINUX 8.2.0
SQL authorization ID = WZM
Local database alias = WZMDB_DB

(8.5)增量备份(两种)说明,在进行增量备份是第一次要全备份,接着才可以进行增量备份
增量备份需要该的参数(trackmod)
[wzm@fedora logs]$ db2 get db cfg for wzmdb | grep -i trackmod
Track modified pages (TRACKMOD) = OFF
[wzm@fedora logs]$ db2 update db cfg for wzmdb using TRACKMOD ON
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
(8.5.1)全备份
[wzm@fedora db2backup]$ db2 backup db wzmdb online to /home/db2backup/ include logs without prompting
Backup successful. The timestamp for this backup image is : 20060521140150
(8.5.2)增量备份
[wzm@fedora db2backup]$ db2 backup db wzmdb online incremental to /home/db2backup/ include logs without prompting
Backup successful. The timestamp for this backup image is : 20060521140301
(8.5.3)备份的恢复(说明先指明恢复的时间点)
[wzm@fedora db2backup]$ db2 restore db wzmdb incremental taken at 20060521140301 into wzmddd logtarget /home/db2backup/logs
DB20000I The RESTORE DATABASE command completed successfully.
(8.5.4)进行一次恢复(恢复到全备份的时间点的内容)
[wzm@fedora db2backup]$ db2 restore db wzmdb incremental taken at 20060521140150 into wzmddd logtarget /home/db2backup/logs
DB20000I The RESTORE DATABASE command completed successfully.
(8.5.5)恢复到所指定的时间点的内容
[wzm@fedora db2backup]$ db2 restore db wzmdb incremental taken at 20060521140301 into wzmddd logtarget /home/db2backup/logs
SQL2580W Warning! Restoring logs to a path which contains existing log files. Attempting to overwrite an existing log file during restore will cause the restore operation to fail.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.

(8.5.6)进行前滚恢复
[wzm@fedora db2backup]$ db2 "rollforward db wzmddd to end of logs and stop overflow log path (home/db2backup/logs)"
Rollforward Status
Input database alias = wzmddd
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000006.LOG - S0000006.LOG
Last committed transaction = 2006-05-21-06.03.12.000000
DB20000I The ROLLFORWARD command completed successfully.

(8.5.7)db2连接
[wzm@fedora db2backup]$ db2 connect to wzmddd
Database Connection Information
Database server = DB2/LINUX 8.2.0
SQL authorization ID = WZM
Local database alias = WZMDDD


39.db2move命令的使用

db2move是一个集成式的数据移动工具,它具有导入(import),导出(export),装入(load)三种操作方法.
db2move导出的数据文件格式是IXF(Integration Exchange Format)集成交换格式.
格式:db2move [ export -tc ] -u -p
参数: -tc 创建表的用户名
      -tn 用户的表名
      -sn 模式名,即导出该模式下的所有表      
查看db2move命令帮助db2move -help

导出test数据库中的全部数据
[db2inst1@localhost ~]$ ls
db2inst1  Sunrier          teacher.sql  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001
sqllib    teacher_bak.txt  teacher.txt
[db2inst1@localhost ~]$ db2move test export -u db2inst1 -p Sunrier

Application code page not determined, using ANSI codepage 1208

*****  DB2MOVE  *****

Action:  EXPORT

Start time:  Fri Aug 17 15:58:34 2012


Connecting to database TEST ... successful!  Server : DB2 Common Server V9.7.1

Binding package automatically ... /home/db2inst1/sqllib/bnd/db2common.bnd ... successful!

Binding package automatically ... /home/db2inst1/sqllib/bnd/db2move.bnd ... successful!

EXPORT:    136 rows from table "SYSTOOLS"."HMON_ATM_INFO"
EXPORT:      0 rows from table "SYSTOOLS"."HMON_COLLECTION"
EXPORT:      3 rows from table "DB2INST1"."PEOPLE"
EXPORT:      5 rows from table "SYSTOOLS"."POLICY"
EXPORT:      3 rows from table "DB2INST1"."STUDENT"
EXPORT:      4 rows from table "DB2INST1"."TEACHER"

Disconnecting from database ... successful!

End time:  Fri Aug 17 15:58:35 2012
[db2inst1@localhost ~]$ ls
db2inst1     sqllib    tab1.msg  tab3.ixf       tab4.ixf  tab5.msg  teacher_bak.txt  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001
db2move.lst  Sunrier   tab2.ixf  tab3.msg       tab4.msg  tab6.ixf  teacher.sql
EXPORT.out   tab1.ixf  tab2.msg  tab4a.001.lob  tab5.ixf  tab6.msg  teacher.txt
[db2inst1@localhost ~]$
注:
  执行上面命令后会把数据库test中全部数据提取到当前目录(/home/db2inst1),每个表的内容都存储在一个.ixf文件中,
  每个.ixf文件都有一个与之相对应的.msg文件,.msg文件是描述从表中导出数据时的信息.例外还有两个文件,db2move.lst用来
  记录.ixf文件,.msg文件与表一一对应.EXPORT.out记录的是导出数据时的屏幕输出.
  
  
导出test数据库中的teacher表中的信息 
[db2inst1@localhost ~]$ ls
db2inst1     Sunrier   teacher.sql  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001  
sqllib teacher_bak.txt  teacher.txt
[db2inst1@localhost ~]$ db2move test export -tn teacher -u db2inst1 -p Sunrier

Application code page not determined, using ANSI codepage 1208

*****  DB2MOVE  *****

Action:  EXPORT

Start time:  Fri Aug 17 16:33:24 2012


All table names matching:  TEACHER;

Connecting to database TEST ... successful!  Server : DB2 Common Server V9.7.1

EXPORT:      4 rows from table "DB2INST1"."TEACHER"

Disconnecting from database ... successful!

End time:  Fri Aug 17 16:33:24 2012
[db2inst1@localhost ~]$ ls
db2inst1     EXPORT.out  Sunrier   tab1.msg         teacher.sql  TEST.0.db2inst1.NODE0000.CATN0000.20120817103306.001
db2move.lst  sqllib      tab1.ixf  teacher_bak.txt  teacher.txt
[db2inst1@localhost ~]$  

 

40.查看test数据库备份的历史记录

格式:db2 list history backup all for
[db2inst1@localhost ~]$ db2 list history backup all for test

                    List History File for test

Number of matching file entries = 4


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  B  D  20120817103306001   F    D  S0000000.LOG S0000000.LOG  
 ----------------------------------------------------------------------------
  Contains 3 tablespace(s):

  00001 SYSCATSPACE                                                          
  00002 USERSPACE1                                                            
  00003 SYSTOOLSPACE                                                          
 ----------------------------------------------------------------------------
    Comment: DB2 BACKUP TEST OFFLINE                                          
 Start Time: 20120817103306
   End Time: 20120817103315
     Status: A
 ----------------------------------------------------------------------------
  EID: 4 Location: /home/db2inst1


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  B  D  20120817150248000   F       S0000000.LOG               
 ----------------------------------------------------------------------------
  Contains 3 tablespace(s):

  00001 SYSCATSPACE                                                          
  00002 USERSPACE1                                                            
  00003 SYSTOOLSPACE                                                          
 ----------------------------------------------------------------------------
    Comment: DB2 BACKUP TEST OFFLINE                                          
 Start Time: 20120817150248
   End Time: 20120817150249
     Status: A
 ----------------------------------------------------------------------------
  EID: 5 Location:


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  B  D  20120817150317001   F    D  S0000000.LOG S0000000.LOG  
 ----------------------------------------------------------------------------
  Contains 3 tablespace(s):

  00001 SYSCATSPACE                                                          
  00002 USERSPACE1                                                            
  00003 SYSTOOLSPACE                                                          
 ----------------------------------------------------------------------------
    Comment: DB2 BACKUP TEST OFFLINE                                          
 Start Time: 20120817150317
   End Time: 20120817150323
     Status: A
 ----------------------------------------------------------------------------
  EID: 6 Location: /home/db2inst1/Sunrier


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  B  D  20120817150825001   F    D  S0000000.LOG S0000000.LOG  
 ----------------------------------------------------------------------------
  Contains 3 tablespace(s):

  00001 SYSCATSPACE                                                          
  00002 USERSPACE1                                                            
  00003 SYSTOOLSPACE                                                          
 ----------------------------------------------------------------------------
    Comment: DB2 BACKUP TEST OFFLINE                                          
 Start Time: 20120817150825
   End Time: 20120817150832
     Status: I
 ----------------------------------------------------------------------------
  EID: 7 Location: /home/db2inst1/Sunrier


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  R  D  20120817151620001   F       S0000000.LOG S0000000.LOG 20120817150317 
 ----------------------------------------------------------------------------
  Contains 3 tablespace(s):

  00001 SYSCATSPACE                                                          
  00002 USERSPACE1                                                            
  00003 SYSTOOLSPACE                                                          
 ----------------------------------------------------------------------------
    Comment: RESTORE TEST NO RF                                               
 Start Time: 20120817151620
   End Time: 20120817151629
     Status: A
 ----------------------------------------------------------------------------
  EID: 8 Location:

[db2inst1@localhost ~]$

 



41.读数据库管理程序配置

db2 get dbm cfg

 

42.写数据库管理程序配置

db2 update dbm cfg using 参数名 参数值

 

43.查看数据库的配置

db2 connect to user using
db2 get db cfg  [ for ]

database:数据库名
username:用户名
password:表示密码

 

44.设置数据库的配置

db2 connect to user using
db2 update db cfg for using 参数名 参数值

 

45.添加DB2服务端口50000

切换到root用户下su - root
[root@localhost etc]# vi /etc/services 
在/etc/services文件中加入db2inst1 50000/tcp

/etc/services内容格式:
# service-name  port/protocol  [aliases ...]   [# comment]

 

46.断开与数据库的连接 

db2 connect reset 或 db2 terminate 
db2 disconnect

 

47.查看命令帮助

[db2inst1@localhost ~]$ db2 ? db2start
{START DATABASE MANAGER | DB2START} [REMOTE [INSTANCE] instance-name
{ADMINNODE node-name | HOSTNAME hostname} USER username USING password]
[ADMIN MODE {USER username | GROUP groupname }] [PROFILE profile]
[DBPARTITIONNUM db-partition-number] [ADD DBPARTITIONNUM HOSTNAME hostname
PORT logical-port [COMPUTER computer-name] [USER username] [PASSWORD password]
[NETNAME netname] [LIKE DBPARTITIONNUM db-partition-number |
WITHOUT TABLESPACES]] | STANDALONE | RESTART [HOSTNAME hostname]
[PORT logical-port] [COMPUTER computer-name] [USER username] [PASSWORD password]
[NETNAME netname] ] ]

NOTE: From the operating system prompt, prefix commands with 'db2'.
      Special characters MAY require an escape sequence (\), for example:
      db2 \? change database
      db2 ? change database xxx comment with \"text\"
[db2inst1@localhost ~]$ 
格式:db2 ?

 

 

48.查看错误码信息

[db2inst1@localhost ~]$ db2 ? 22003

SQLSTATE 22003: A numeric value is out of range.

[db2inst1@localhost ~]$ 
格式:db2 ?



49.提交

db2 commit

50. 设置当前连接的schema 

db2 set current schema schema_name 

51.重命名表 

db2 "rename table table_old to table_new" 

51.给实例增加端口号

vi/etc/services
DB2_db2inst1 60000/tcp
DB2_db2inst1_1 60001/tcp
DB2_db2inst1_2 60002/tcp
DB2_db2inst1_END 60003/tcp
DB2_dl 60004/tcp
DB2_dl_1 60005/tcp
DB2_dl_2 60006/tcp
DB2_dl_END 60007/tcp
#DB2tcp 50000/tcp
#DB2tcp1 50001/tcp
DB2_qing 60008/tcp
DB2_qing_1 60009/tcp
DB2_qing_2 60010/tcp
DB2_qing_END 60011/tcp
#
db2_master 50506/tcp
db2_slave 50505/tcp
DB2_wzm 60012/tcp
DB2_wzm_1 60013/tcp
DB2_wzm_2 60014/tcp
DB2_wzm_END 60015/tcp

把dbm的VCENAME 的值和/etc/services中的端口号 对应
[wzm@fedora ~]$ db2 update dbm cfg using SVCENAME 50000
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed

查看监听端口
[wzm@fedora db2backup]$ netstat -an | grep 50000
tcp 0 0 0.0.0.0:50000 0.0.0.0:* LISTEN
说明:综合上述的更改,这时 就可以远程连接到实例。

52.数据库的远程编目

===========================================================================
(6.1) 编目节点
[dl@fedora ~]$ db2 catalog tcpip node wzmode remote 10.4.5.212 server 50000
DB20000I The CATALOG TCPIP NODE command completed successfully.
DB21056W Directory changes may not be effective until the directory cache is
refreshed.

(6.2)显示编目的接点
[dl@fedora ~]$ db2 list node directory
Node Directory
Number of entries in the directory = 2
Node 1 entry:
Node name = WZMODE
Comment =
Directory entry type = LOCAL
Protocol = TCPIP
Hostname = 10.4.5.212
Service name = 50000

(6.3)编目远程的数据库到节点
[dl@fedora ~]$ db2 catalog db wzmdb as wzmdb_bm at node wzmode
DB20000I The CATALOG DATABASE command completed successfully.
DB21056W Directory changes may not be effective until the directory cache is
refreshed.
(6.4) 显示编目的数据库
[dl@fedora ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 3

Database 1 entry:
Database alias = WZMDB_BM
Database name = WZMDB
Node name = WZMODE
Database release level = a.00
Comment =
Directory entry type = Remote
Catalog database partition number = -1
Alternate server hostname =
Alternate server port number =

(6.4)连接编目的数据库
[dl@fedora ~]$ db2 connect to wzmdb_bm user wzm using 123456
Database Connection Information
Database server = DB2/LINUX 8.2.0
SQL authorization ID = WZM
Local database alias = WZMDB_BM
(6.5) 显示编目数据库的内容
[dl@fedora ~]$ db2 list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
WZMTB WZM T 2006-05-20-14.46.34.953560
1 record(s) selected.

53.数据库中的数据移动

================================================================================
(7.1) 将表中的数据导出
[wzm@fedora db2backup]$ db2 "export to wzmtb.ixf of ixf messages wzm.out select * from wzmtb"
Number of rows exported: 1
(7.2) 将数据导入
[wzm@fedora db2backup]$ db2 "import from wzmtb.ixf of ixf messages wzm.out create into wzmtb_tb"
Number of rows read = 1
Number of rows skipped = 0
Number of rows inserted = 1
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1
(7.3)显示到入的内容
[wzm@fedora db2backup]$ db2 list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
WZMTB WZM T 2006-05-20-14.46.34.953560
WZMTB_TB WZM T 2006-05-20-17.43.52.010679
2 record(s) selected.
(7.4) 另一种的数据到入方法(说明,首先要建一个和原来表结构一样的表)
[wzm@fedora db2backup]$ db2 "load from wzmtb.ixf of ixf messages wzm.out insert into wzmtb_tb_tb"
Number of rows read = 1
Number of rows skipped = 0
Number of rows loaded = 1
Number of rows rejected = 0
Number of rows deleted = 0
Number of rows committed = 1

54.HADR的配置

=======================================================
说明:
一。主服务器10.4.5.212 重服务器10.4.5.210
二。进行hadr的配置需要数据库的名字相同,但实例名字可以不同。
三。db2 update db cfg for wzmdb using LOGINDEXBUILD on

1.首先对主数据库进行一次全备份
[wzm@fedora db2backup]$ db2 backup db wzmdb
Backup successful. The timestamp for this backup image is : 20060521165702

2.将备份考到重服务器上
[wzm@fedora db2backup]$ scp WZMDB.0.wzm.NODE0000.CATN0000.20060521165702.001 [email protected]:/home/dl/db2backup/
[email protected]''s password:
WZMDB.0.wzm.NODE0000.CATN0000.20060521165702.001 100% 35MB 1.3MB/s 00:26
3.对重服务器进行数据库的恢复
[dl@fedora db2backup]$ db2 restore db wzmdb taken at 20060521165702
SQL2539W Warning! Restoring to an existing database that is the same as the ba ckup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.

4.修改之后的配置文件
[wzm@fedora db2backup]$ db2 get db cfg for wzmdb | grep -i hadr
HADR database role = STANDARD
HADR local host name (HADR_LOCAL_HOST) = 10.4.5.212
HADR local service name (HADR_LOCAL_SVC) = wzm8
HADR remote host name (HADR_REMOTE_HOST) = 10.4.5.210
HADR remote service name (HADR_REMOTE_SVC) = wzm9
HADR instance name of remote server (HADR_REMOTE_INST) = dl
HADR timeout value (HADR_TIMEOUT) = 120
HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC

同理
[dl@fedora db2backup]$ db2 get db cfg for wzmdb | grep -i hadr
HADR database role = STANDARD
HADR local host name (HADR_LOCAL_HOST) = 10.4.5.210
HADR local service name (HADR_LOCAL_SVC) = wzm9
HADR remote host name (HADR_REMOTE_HOST) = 10.4.5.212
HADR remote service name (HADR_REMOTE_SVC) = wzm8
HADR instance name of remote server (HADR_REMOTE_INST) = wzm
HADR timeout value (HADR_TIMEOUT) = 120
HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC
5.启动重服务器
[dl@fedora ~]$ db2 start hadr on db wzmdb as standby
DB20000I The START HADR ON DATABASE command completed successfully.
6.启动主服务器
[wzm@fedora db2backup]$ db2 start hadr on db wzmdb as primary
DB20000I The START HADR ON DATABASE command completed successfully.

7.查看hadr的状态为peer状态。
[dl@fedora ~]$ db2pd -hadr -db wzmdb
Database Partition 0 -- Database WZMDB -- Active -- Up 0 days 00:01:15
HADR Information:
Role State SyncMode HeartBeat LogGapRunAvg (bytes)
Standby Peer Nearsync 0 0
ConnectStatus ConnectTime Timeout
Connected Sun May 21 13:40:57 2006 (1148190057) 120
LocalHost LocalService RemoteHost RemoteService RemoteInstance
10.4.5.210 wzm9
10.4.5.212 wzm8 wzm
PrimaryFile PrimaryPg PrimaryLSN StandByFile StandByPg StandByLSN
S0000007.LOG 0 0x000002AF800080AB3C43A0 5E0 S0000007.LOG 0 0x000002AF800080AB3C43A0 5E0

[wzm@fedora db2backup]$ db2pd -hadr -db wzmdb
Database Partition 0 -- Database WZMDB -- Active -- Up 0 days 00:00:33
HADR Information:
Role State SyncMode HeartBeat LogGapRunAvg (bytes)
Primary Peer Nearsync 0 0
ConnectStatus ConnectTime Timeout
Connected Sun May 21 17:18:39 2006 (1148203119) 120
LocalHost LocalService RemoteHost RemoteService RemoteInstance
10.4.5.212 wzm8
10.4.5.210 wzm9 dl
PrimaryFile PrimaryPg PrimaryLSN StandByFile StandByPg StandByLSN
S0000007.LOG 0 0x000002AF800080AB3C46C5 5E0 S0000007.LOG 0 0x000002AF800080AB3



整理自:
http://blog.csdn.net/sunrier/article/details/7835578
http://blog.sina.com.cn/s/blog_60359c5b0100hj0e.html
http://www.ibm.com/developerworks/cn/data/library/techarticles/0211yip2/#ibm-pcon





 



你可能感兴趣的:(DB2@BK)