db2 "select 'export to ' || rtrim(tabname) || '.ixf of ixf select * from ' || rtrim(tabname) || ';' from syscat.tables where tabschema = 'DB2INST1'" > export.sql
4) 编辑生成的export.sql,把头和尾那些信息去掉,只保留必要的export命令.
5) 使用下面的SQL语句生成倒入所有数据的脚本(我们使用LOAD命令,而且必须使用)
以下是代码片段:
db2 "select 'load from ' || rtrim(tabname) || '.ixf of ixf insert into ' || rtrim(tabname) || ';' from syscat.tables where tabschema = 'DB2INST1'" > load.sql
6) 编辑生成的load.sql,把头和尾的信息去掉,只保留必要的load命令.搜索sample_tabs.ddl文件中哪些表含有自增字段(含有GENERATED ALWAYS AS IDENTITY定义的字段的表),并把load.sql中含有自增字段的表的load命令加入modified by identityoverride语句(加在of ixf和 insert之间,例如: load from MYTABLE.ixf of ixf modified by identityoverride insert into MYTABLE
注意:load命令中的modified by identityoverride可以保证DB2数据时那些自增字段的值和原数据库中的数据一致.