db2导入导出
环境:
OS:Centos 7
DB:V11.5.6
1.导出表(默认是逗号分隔)
db2 connect db_hxl
db2 EXPORT TO /tmp/tb_test.txt OF del "SELECT * FROM tb_test01"
文件内容:
[root@localhost tmp]# more tb_test.txt
1,"hxl",20
2,"hxl01",30
@分割
db2 "EXPORT TO /tmp/tb_test01.txt OF del modified by coldel@ SELECT * FROM tb_test01"
@后面需要带上空格
去掉字符串的双引号
db2 "EXPORT TO /tmp/tb_test01.txt OF del modified by coldel@ nochardel SELECT * FROM tb_test01"
2.导入
导入:
db2 connect to db_hxl
db2 import from /tmp/tb_test01.txt of del insert into tb_test01;
导出(指定分割符):
db2 "EXPORT TO /tmp/tb_test01.txt OF del modified by coldel@ nochardel SELECT * FROM tb_test01"
导入(指定分割符):
db2 connect to db_hxl
db2 import from /tmp/tb_test01.txt of del modified by coldel@ nochardel insert into tb_test01;
3.导出数据库下所有的表结构
db2look -d db_hxl -z db2inst1 -e -o db_hxl.sql
-d:数据库名称
-z:模式名,不指定的话就是实例名
导出具体表的表结构
db2look -d db_hxl -e -t tb_test01 -o tb_test01.sql