【ibm体重指数】IBM DB2 的数据复制、迁移方法
【shitiku.jxxyjl.com--IBM认证经验交流】
以下方法经测试,在环境ibm x346,3.2g×2,4g,raid 1,db2 v8.2.4,win2000 adv server,dms表空间中,数据的load速度在60-100万条/min左右。
背景:需要更改数据库表空间,或者需要将数据库中所有表的数据迁移到一个新的数据库中。 步骤: 1.通过db2控制台(db2cc)选中源数据库中的所有表,将其导出成ddl脚本; 2.根据需要对脚本进行必要的修改,譬如更改表空间为gather; 3.新建数据库,新建dms表空间:gather; 4.将ddl脚本在此数据库中执行; 5.编写代码查询源数据库中的所有表,自动生成export脚本; 6.编写代码查询源数据库中的所有表,自动生成import脚本; 7.连接源数据库执行export脚本; 8.连接目标数据库执行import脚本;附录1:生成export脚本代码示例: /** * 创建导出脚本 * @param conn * @param creator 表创建者 * @param filepath */ public void createexportfile(connection conn,string creator,string filepath) throws exception { dbbase dbbase = new dbbase(conn); string selecttablesql = "select name from sysibm.systables where creator = "" + creator + "" and type="t""; try { dbbase.executequery(selecttablesql); } catch (exception ex) { throw ex; } finally { dbbase.close(); } dbresult result = dbbase.getselectdbresult(); list list = new arraylist(); while (result.next()) { string table = result.getstring(1); list.add(table); } stringbuffer sb = new stringbuffer(); string enterflag = "\r\n"; for (int i = 0; i < list.size();i++) { string tablename = (string)list.get(i); sb.append("db2 \"export to aa" + string.valueof(i+1)+ ".ixf of ixf select * from " + tablename + "\""); sb.append(enterflag); } string str = sb.tostring(); fileutility.savestringtofile(filepath, str, false); } 附录2:生成import脚本代码示例: /** * 创建装载脚本 * @param conn * @param creator 表创建者 * @param filepath */ public void createloadfile(connection conn,string creator,string filepath) throws exception { dbbase dbbase = new dbbase(conn); string selecttablesql = "select name from sysibm.systables where creator = "" + creator + "" and type="t""; try { dbbase.executequery(selecttablesql); } catch (exception ex) { throw ex; } finally { dbbase.close(); } dbresult result = dbbase.getselectdbresult(); list list = new arraylist(); while (result.next()) { string table = result.getstring(1); list.add(table); } stringbuffer sb = new stringbuffer(); string enterflag = "\r\n"; for (int i = 0; i < list.size();i++) { string tablename = (string)list.get(i); sb.append("db2 \"load from aa" + string.valueof(i+1)+ ".ixf of ixf into " + tablename + " copy no without prompting \""); sb.append(enterflag); } string str = sb.tostring(); fileutility.savestringtofile(filepath, str, false); }
附录3:export脚本示例 db2 connect to testdb user test password test db2 "export to aa1.ixf of ixf select * from table1" db2 "export to aa2.ixf of ixf select * from table2" db2 connect reset
附录4:import脚本示例 db2 connect to testdb user test password test db2 "load from aa1.ixf of ixf replace into table1 copy no without prompting " db2 "load from aa2.ixf of ixf replace into table2 copy no without prompting " db2 connect reset
本文来源:https://shitiku.jxxyjl.com/ibmrenzhengjingyanjiaoliu/6112.html
-
基准tpc指标值|TPC基准程序及tpmc值详细阅读
─兼谈在使用性能度量时如何避免误区 今天的用户在选用平台时面对的是一个缤纷繁杂的世界。用户希望有一 种度量标准,能够量化计算机系统的性能,以此作为选型的依据。作者曾在美国从 事过数年计算机性能评价工作,深深体会到,计算机的性能很难用一两种度量来 评价,而且,任何度量都有其优缺点,尤其是当使用者对...
-
ibm体重指数_IBM 存储解决方案:电子商务的选择(1)详细阅读
为什么您需要灾难恢复计划? 当企业越来越依赖于数据去进行处理它的商业行为以及由此来保证它在业界的竞争力的时候,数据处理的高可靠性和高可用性就尤为关键。一个计算机系统的长期停止将直接导致明显的财务流失,更为重要的是,您将失去客户的信任以及一系列的企业赖以生存发展的市场...
-
网络控制的核心是|网络是核心—IBM看下一代技术详细阅读
本文的内容是ibm对it下一代技术发展的5个预言,其中,除了it产 品在速度、体积等方面将有进一步突破外,其余的四大技术趋势均是基于网络的技术。由此,透过ibm的观点,我们可以看到下一代it技术对人类的影响将通过技术改变网络,网络改变人类的路径来完成。 ibm研究部门在全球设立了8个...
-
基准tpc指标值|TPC基准程序 及tpmc值详细阅读
今天的用户在选用平台时面对的是一个缤纷繁杂的世界。用户希望有一 种度量标准,能够量化计算机系统的性能,以此作为选型的依据。作者曾在美国从 事过数年计算机性能评价工作,深深体会到,计算机的性能很难用一两种度量来 评价,而且,任何度量都有其优缺点,尤其是当使用者对性能度量了解不深时,很...