自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

IBM DB2的數(shù)據(jù)復(fù)制與遷移方法淘寶級

數(shù)據(jù)庫
以下的文章主要向大家描述的是IBM DB2的數(shù)據(jù)復(fù)制與遷移方法的介紹,以及對其的操作背景的描述,以下就是正文的主要內(nèi)容講述。

文章主要向大家描述的是IBM DB2的數(shù)據(jù)復(fù)制與遷移方法的介紹,以下就是對IBM DB2的數(shù)據(jù)復(fù)制與遷移方法的介紹的詳細(xì)描述,望大家在瀏覽之后會(huì)對IBM DB2的數(shù)據(jù)復(fù)制與遷移有更深的了解。

IBM, 數(shù)據(jù), 遷移, 講解IBM, 數(shù)據(jù), 遷移, 講解

 

關(guān)鍵詞: 遷移 , 復(fù)制 , 方法 , IBM , DB2 , 數(shù)據(jù)

 

 

以下方法經(jīng)測試,在環(huán)境IBM x346,3.2G×2,4G,RAID 1,DB2 V8.2.4,Win2000 Adv Server,DMS表空間中,數(shù)據(jù)的load速度在60-100萬條/min左右。

背景:

需要更改數(shù)據(jù)庫表空間,或者需要將數(shù)據(jù)庫中所有表的數(shù)據(jù)遷移到一個(gè)新的數(shù)據(jù)庫中。

 

IBM DB2的數(shù)據(jù)復(fù)制和遷移步驟:

1.通過db2控制臺(tái)(db2cc)選中源數(shù)據(jù)庫中的所有表,將其導(dǎo)出成DDL腳本;

 

2.根據(jù)需要對腳本進(jìn)行必要的修改,譬如更改表空間為GATHER;

 

3.新建數(shù)據(jù)庫,新建DMS表空間:GATHER;

 

4.將DDL腳本在此數(shù)據(jù)庫中執(zhí)行;

 

5.編寫代碼查詢源數(shù)據(jù)庫中的所有表,自動(dòng)生成export腳本;

 

6.編寫代碼查詢源數(shù)據(jù)庫中的所有表,自動(dòng)生成import腳本;

 

7.連接源數(shù)據(jù)庫執(zhí)行export腳本;

 

8.連接目標(biāo)數(shù)據(jù)庫執(zhí)行import腳本;

 

附錄1:生成export腳本代碼示例:

  1. /**     
  2. * 創(chuàng)建導(dǎo)出腳本     
  3. * @param conn     
  4. * @param creator 表創(chuàng)建者     
  5. * @param filePath     
  6. */     
  7. public void createExportFile(Connection conn,String creator,String filePath) throws Exception {     
  8. DBBase dbBase = new DBBase(conn);     
  9. String selectTableSql = "select name from sysibm.systables where creator = '" + creator + "' and type='T'";     
  10. try {     
  11. dbBase.executeQuery(selectTableSql);     
  12. } catch (Exception ex) {     
  13. throw ex;     
  14. } finally {     
  15. dbBase.close();     
  16. }     
  17. DBResult result = dbBase.getSelectDBResult();     
  18. List list = new ArrayList();     
  19. while (result.next()) {     
  20. String table = result.getString(1);     
  21. list.add(table);     
  22. }     
  23. StringBuffer sb = new StringBuffer();     
  24. String enterFlag = "\r\n";     
  25. for (int i = 0; i < list.size();i++) {     
  26. String tableName = (String)list.get(i);     
  27. sb.append("db2 \"export to aa" + String.valueOf(i+1)+ ".ixf of ixf select * from " + tableName + "\"");     
  28. sb.append(enterFlag);     
  29. }     
  30. String str = sb.toString();     
  31. FileUtility.saveStringToFile(filePath, str, false);     
  32. }     

附錄2:生成import腳本代碼示例:

  1. /**     
  2. *創(chuàng)建裝載腳本     
  3. * @param conn     
  4. * @param creator 表創(chuàng)建者     
  5. * @param filePath     
  6. */     
  7. public void createLoadFile(Connection conn,String creator,String filePath) throws Exception {     
  8. DBBase dbBase = new DBBase(conn);     
  9. String selectTableSql = "select name from sysibm.systables where creator = '" + creator + "' and type='T'";     
  10. try {     
  11. dbBase.executeQuery(selectTableSql);     
  12. } catch (Exception ex) {     
  13. throw ex;     
  14. } finally {     
  15. dbBase.close();     
  16. }     
  17. DBResult result = dbBase.getSelectDBResult();     
  18. List list = new ArrayList();     
  19. while (result.next()) {     
  20. String table = result.getString(1);     
  21. list.add(table);     
  22. }     
  23. StringBuffer sb = new StringBuffer();     
  24. String enterFlag = "\r\n";     
  25. for (int i = 0; i < list.size();i++) {     
  26. string tableName = (String)list.get(i);     
  27. sb.append("db2 \"load from aa" + String.valueOf(i+1)+ ".ixf of ixf into " + tableName + " COPY NO without prompting \"");   sb.append(enterFlag);     
  28. }     
  29. String str = sb.toString();     
  30. FileUtility.saveStringToFile(filePath, str, false);     
  31. }     

附錄3:export腳本示例

  1. db2 connect to testdb user test password test     
  2. db2 "export to aa1.ixf of ixf select * from table1"     
  3. db2 "export to aa2.ixf of ixf select * from table2"     
  4. db2 connect reset       

附錄4:import腳本示例

  1. db2 connect to testdb user test password test     
  2. db2 "load from aa1.ixf of ixf replace into table1 COPY NO without prompting "     
  3. db2 "load from aa2.ixf of ixf replace into table2 COPY NO without prompting "     
  4. db2 connect reset   

以上的相關(guān)內(nèi)容就是對IBM DB2的數(shù)據(jù)復(fù)制和遷移方法的介紹,望你能有所收獲。

【編輯推薦】

  1. 手動(dòng)安裝DB2數(shù)據(jù)庫的實(shí)現(xiàn)在UNIX操作環(huán)境下
  2. DB2卸載后正確巧妙恢復(fù)原來數(shù)據(jù)庫中的某些數(shù)據(jù)
  3. DB2數(shù)據(jù)庫備份參數(shù)修改后報(bào)錯(cuò)如何拯救?
  4. DB2 V9.7啟用索引壓縮大揭秘
  5. import 或是 load多個(gè)DB2主從表談何容易?

     

     
責(zé)任編輯:佚名 來源: 人民郵電出版社
相關(guān)推薦

2011-03-16 13:02:47

DB2數(shù)據(jù)復(fù)制遷移

2010-08-12 10:34:40

IBM DB2數(shù)據(jù)

2010-08-10 14:02:26

IBM DB2數(shù)據(jù)復(fù)制

2010-08-04 12:39:55

2010-08-20 13:39:23

DB2數(shù)據(jù)復(fù)制

2010-08-13 10:13:15

DB2數(shù)據(jù)復(fù)制

2010-08-19 10:32:07

BM DB2數(shù)據(jù)復(fù)制

2010-08-06 11:21:45

IBM DB2 數(shù)據(jù)復(fù)

2010-08-13 16:29:03

DB2數(shù)據(jù)復(fù)制

2009-07-06 17:34:26

遠(yuǎn)程復(fù)制DB2

2010-08-17 16:24:32

IBM DB2數(shù)據(jù)庫

2010-09-01 11:17:29

DB2備份

2010-08-19 17:41:46

IBM DB2跨平臺(tái)數(shù)

2009-03-25 17:43:09

備份DB2IBM

2010-08-13 18:06:03

IBM DB2

2012-02-26 16:58:48

DB2數(shù)據(jù)庫遷移之星

2011-09-23 09:41:58

2010-08-13 09:43:13

IBM DB2

2010-09-01 13:38:41

DB2數(shù)據(jù)復(fù)制

2010-08-11 09:14:33

DB2數(shù)據(jù)類型
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號