db2move 备份还原

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huryer/article/details/80353350

db2move 备份还原

## 数据导出:
db2move dbname EXPORT
db2move dbname EXPORT -u userName -p password

-- 数据导出时,忽略警告信息
db2move dbname EXPORT -aw

-- 按表名导出
db2move dbname export -tn tablename -u userName -p password
db2move dbname export -sn schemaName -tn tableName -u userName -p password -aw

-- 数据导入:
db2move dbname import -u userName -p psw

-- 数据装载(被装载的表必须存在)
db2move dbname load

## db2move 命令测试

-- 准备测试数据
drop table t;
create table t(id int not null,
 name varchar(20),
 constraint pk_t primary key(id));
insert into t(id,name) values(1,'hury');
insert into t(id,name) values(2,'lj');
insert into t(id,name) values(3,'song');
update t set name = 'hury1' where id = 1;
select * from t;

-- 导出测试数据
db2move db_test export -aw -tn t

## 数据导入 db2move ... import
 -io <value>  IMPORT specific actions.      IMPORT   One of: INSERT,
               Default is REPLACE_CREATE               INSERT_UPDATE, REPLACE,
               (see docs for limitations               CREATE, REPLACE_CREATE
                of Import create function)

-- 默认模式 替换创建表
db2move db_test import

-- 仅执行数据插入,如果数据已存在,则标记为拒绝:Rejected
db2move db_test import -io insert 

-- 替换原有数据插入
db2move db_test import -io replace

-- 创建表,并写入数据;如果有表,报错:
-- SQL3305N  The table cannot be created because it already exists.
db2move db_test import -io create

-- 插入更新
db2move db_test import -io INSERT_UPDATE

-- 替换创建表
db2move db_test import -io REPLACE_CREATE

## db2move ... load
 -lo <value>  LOAD specific options.        LOAD     One of: INSERT,
                Default is INSERT                      REPLACE

-- 加载新数据:默认操作 insert 
db2move db_test load

-- 加载数据,insert:仅插入新数据
db2move db_test load -lo insert 

-- 加载数据,replace:替换原有数据
db2move db_test load -lo replace