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

IBM DB2數(shù)據(jù)復(fù)制與遷移方法的背景與實(shí)際操作步驟

數(shù)據(jù)庫(kù)
我們今天主要向大家講述的是IBM DB2數(shù)據(jù)復(fù)制與遷移方法的描述,以及對(duì)其在實(shí)際操作中要遇到的一些問(wèn)題的描述,以下就是文章的主要內(nèi)容講述。

文章主要講述的是IBM DB2數(shù)據(jù)復(fù)制與遷移方法的描述,下面的這些方法都是經(jīng)過(guò)相關(guān)經(jīng)測(cè)試,在環(huán)境IBM x346,3.2G×2,4G,RAID 1,DB2 V8.2.4,Win2000 Adv Server,DMS表空間中,數(shù)據(jù)的load速度在60-100萬(wàn)條/min左右。

背景:

 

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

步驟:

 

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

 

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

 

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

 

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

 

5.編寫(xiě)代碼查詢?cè)磾?shù)據(jù)庫(kù)中的所有表,自動(dòng)生成export腳本;

 

6.編寫(xiě)代碼查詢?cè)磾?shù)據(jù)庫(kù)中的所有表,自動(dòng)生成import腳本;

 

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

 

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

 

 

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

/**

 

* 創(chuàng)建導(dǎo)出腳本

 

 

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

 

 

 

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

/**

 

* 創(chuàng)建裝載腳本

 

* @param conn

 

* @param creator 表創(chuàng)建者

 

 

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

 

 

 

附錄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  
  5. TAG: IBM ibm   

 

 

 

責(zé)任編輯:佚名 來(lái)源: wpzune
點(diǎn)贊
收藏

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