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

DB2數(shù)據(jù)復制與遷移的操作方案大盤點

數(shù)據(jù)庫
我們今天主要向大家描述的是DB2數(shù)據(jù)復制與遷移的實際操作方法的描述,以及對其在實際操作中所涉及到的實際操作步驟的描述。

此文章主要向大家介紹的是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ù)遷移到一個新的數(shù)據(jù)庫中。

步驟:

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

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

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

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

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

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

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

8. 連接目標DB2數(shù)據(jù)復制執(zhí)行import腳本;

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

 

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

 

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

 

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

 

附錄3:export腳本示例db2 connect to testdb user test password test

 

  1. db2 "export to aa1.ixf of ixf select * from table1"  
  2. db2 "export to aa2.ixf of ixf select * from table2"  
  3. db2 connect reset  

 

附錄4:import腳本示例db2 connect to testdb user test password test

 

  1. db2 "load from aa1.ixf of ixf replace into table1 COPY NO without prompting "  
  2. db2 "load from aa2.ixf of ixf replace into table2 COPY NO without prompting "  
  3. db2 connect reset  

 

 

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

【編輯推薦】

  1. IBM DB2中新手要了解的東西有哪些?
  2. IBM DB2 Content Manager V83安裝與SQL0818
  3. 掛起DB2 diag.log中看到了什么?
  4. DB2 CM ls對應的Content Manager版本級別的確認
  5. DB2V8升級到DB2V95在AIX平臺上很簡單
     

 

責任編輯:佚名 來源: 51soso.net/
相關推薦

2011-03-16 13:02:47

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

2010-08-09 12:56:11

2010-08-12 10:34:40

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

2010-08-17 10:06:25

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

2010-08-13 10:13:15

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

2010-08-10 14:02:26

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

2010-08-19 10:32:07

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

2010-08-13 16:29:03

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

2010-08-12 15:23:18

DB2數(shù)據(jù)遷移

2009-07-06 17:34:26

遠程復制DB2

2010-08-04 12:39:55

2010-11-02 14:53:38

DB2權限

2010-08-20 14:31:32

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

2010-08-03 13:56:11

DB2表復制

2010-08-05 09:47:01

DB2常用函數(shù)

2010-08-17 13:00:19

DB2數(shù)據(jù)遷移

2010-08-17 09:18:29

DB2 備份

2010-08-17 13:37:18

DB2 Online

2010-08-02 10:28:38

DB2 存儲過程

2010-09-01 13:38:41

DB2數(shù)據(jù)復制
點贊
收藏

51CTO技術棧公眾號