一、整库备份(备份数据为一个文件)
1)备份之前断开所有连接
db2 force application all
2)备份
db2 backup db dbname user db2admin using db2admin to d:/
3)恢复
db2 restore db dbname user db2admin using db2admin from d:/
二、按模式备份(备份数据为多个文件)
1)备份表结构
db2look -d dbname -e -a -x -i db2admin -w db2admin -o d:\createdb.sql
2)导出数据(进入到指定目录后执行)
db2move dbname export -u db2admin -p db2admin
3)导入表结构
db2 -tvf createdb.sql
4)导入数据(进入到指定目录后执行)
db2move dbname import -u db2admin -p db2admin
三、以文本方式导入导出某个表(数据量较小的表)
1)导出
export to d:\dbtable.txt of del select * from dbtable;
2)导入
import from d:\dbtable.txt of del insert into dbtable;
3)导入乱码
import from d:\dbtable.txt of del modified by codepage=1208 insert into dbtable;
codepage=1208 为UTF-8
codepage=1386 为GBK