今天是要和大家一起讨论的是在Linux操作平台下正确实现DB2数据库迁移之导入的实际操作步骤,如果你对DB2数据库迁移之导入的实际操作步骤,心存好奇的话,以下的文章将会揭开它的神秘面纱。
(1)解压
主要命令:
- tar zxfv oatest0303.tar.gz
- [db2inst1@devsvr2 db2inst1]$ tar zxfv oatest0303.tar.gz
- oatest0303/
- oatest0303/oatest.sql
- oatest0303/EXPORT.out
- oatest0303/db2move.lst
- ……
(2)建立新数据库 db2 create db sample
主要命令:
- db2 create db sample
- [db2inst1@devsvr2 db2inst1]$ db2 create db sample
DB20000I CREATE DATABASE 命令成功完成。
(3)执行 oatest.sql 脚本建立数据库
主要命令:
- db2 -tvf oatest.sql
- [db2inst1@devsvr2 db2inst1]$ cd oatest0303
- [db2inst1@devsvr2 oatest0303]$ db2 -tvf oatest.sql
- ……
(4)执行 db2move在Linux平台下进行DB2数据库迁移之导入步骤之导入数据
主要命令:
- db2move sample load
- [db2inst1@devsvr2 oatest0303]$ db2move sample load
- ……
- * LOAD: table "OATEST "."UM_USER"
- -Rows read: 1529
- -Loaded: 1529
- -Rejected: 0
- -Deleted: 0
- -Committed: 1529
- Disconnecting from database ... successful!
- End time: Sun Mar 5 10:24:22 2006
(5)检查一致性
主要命令:
- db2 set integrity for oatest.UM_USER immediate checked
- [db2inst1@devsvr2 oatest0303]$ db2 connect to sample
数据库连接信息
数据库服务器 = DB2/LINUX 8.2.0
SQL 授权标识 = DB2INST1
本地数据库别名 = SAMPLE
- [db2inst1@devsvr2 oatest0303]$ db2 "select count(*) from
- oatest.um_user"
- 1
SQL0668N 由于表 "OATEST.UM_USER" 上的原因码 "1",所以不允许操作。
- SQLSTATE=57016
- [db2inst1@devsvr2 oatest0303]$ db2 set integrity for oatest.UM_USER
- immediate checked
DB20000I SQL 命令成功完成。
- [db2inst1@devsvr2 oatest0303]$ db2 "select count(*) from
- oatest.um_user"
- 1
- 1529
1 条记录已选择。
利用 sql 语句得到要检查的表的执行语句#p#
主要命令:
- db2 "select 'db2 set integrity for oatest.'||TABNAME||' immediatechecked' from syscat.tables where TABSCHEMA='OATEST' and STATUS='C'"
- [db2inst1@devsvr2 oatest0303]$ db2 "select 'db2 set
- integrity for oatest.'||TABNAME||' immediate checked'
- from syscat.tables where TABSCHEMA='OATEST' and STATUS='C'"
- 1
- db2 set integrity for oatest.CAL_AUTH immediate checked
- ……
- db2 set integrity for oatest.UM_USER immediate checked
81 条记录已选择。
执行这 81 条语句,在Linux平台下进行DB2数据库迁移之导入步骤之语句有可能报错
主要命令:
- db2 set integrity for oatest. CAL_AUTH immediate checked
- [db2inst1@devsvr2 oatest0303]$ db2 set integrity
- for oatest.CAL_AUTH immediate checked
DB20000I SQL 命令成功完成。
- [db2inst1@devsvr2 oatest0303]$ db2 set integrity
- for oatest.UM_USER immediate checked
DB20000I SQL 命令成功完成。
…………
如果报错,再反复执行这些语句直到下面的语句结果返回 0 条记录
- [db2inst1@devsvr2 oatest0303]$ db2 "select 'db2 set integrity
- for oatest.'||TABNAME||' immediate checked' from syscat.tables
- where TABSCHEMA='OATEST' and STATUS='C'"
- 1
0 条记录已选择。
(6)在操作系统中建立用户
- [root@devsvr2 root]# useradd oatest
- [root@devsvr2 root]# passwd oatest
- Changing password for user oatest.
- New password:
- BAD PASSWORD: it is too short
- Retype new password:
- passwd: all authentication tokens updated successfully.
(7)给 oatest 用户授权
主要命令:
- db2 GRANTDBADM,CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,
- IMPLICIT_SCHEMA,LOAD,CREAT
- E_EXTERNAL_ROUTINE,QUIESCE_CONNECTON DATABASE TO USER OATEST
- db2 GRANT CREATEIN,DROPIN,ALTERIN ON SCHEMA OATEST TO USER OATEST
- [db2inst1@devsvr2 db2inst1]$ db2 connect to sample
数据库连接信息
数据库服务器 = DB2/LINUX 8.2.0
SQL 授权标识 = DB2INST1
本地数据库别名 = SAMPLE
- [db2inst1@devsvr2 db2inst1]$ db2 GRANT DBADM,CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,
- IMPLICIT_SCHEMA,LOAD,CREATE_EXTERNAL_ROUTINE,
- QUIESCE_CONNECT ON DATABASE TO USER OATEST;
DB20000I SQL 命令成功完成。
- [db2inst1@devsvr2 db2inst1]$ db2 GRANT CREATEIN,
- DROPIN,ALTERIN ON SCHEMA OATEST TO USER OATEST
DB20000I SQL 命令成功完成。
- [db2inst1@devsvr2 db2inst1]$ db2 connect to sample user oatest using oatest
数据库连接信息
数据库服务器 = DB2/LINUX 8.2.0
SQL 授权标识 =OATSET
本地数据库别名 = SAMPLE
- [db2inst1@devsvr2 db2inst1]$ db2 "select count(*) from um_user"
- 1
- 1529
1 条记录已选择。以上的相关内容就是对在Linux平台下进行DB2数据库迁移之导入步骤的介绍,望你能有所收获。