av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

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

瀏覽:62日期:2023-11-11 11:53:26
背景:需要更改數(shù)據(jù)庫表空間,或者需要將數(shù)據(jù)庫中所有表的數(shù)據(jù)遷移到一個新的數(shù)據(jù)庫中。步驟:1.通過db2控制臺(db2cc)選中源數(shù)據(jù)庫中的所有表,將其導(dǎo)出成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.連接目標(biāo)數(shù)據(jù)庫執(zhí)行import腳本;附錄1:生成export腳本代碼示例:/*** 創(chuàng)建導(dǎo)出腳本* @param conn* @param creator 表創(chuàng)建者* @param filePath*/* 創(chuàng)建導(dǎo)出腳本* @param conn* @param creator 表創(chuàng)建者* @param filePathpublic 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 = "";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腳本代碼示例/*** 創(chuàng)建裝載腳本* @param conn* @param creator 表創(chuàng)建者* @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 = "";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腳本示例db2connecttotestdbusertestpasswordtestdb2"exporttoaa1.ixfofixfselect*fromtable1"db2"exporttoaa2.ixfofixfselect*fromtable2"db2connectreset附錄4:import腳本示例db2connecttotestdbusertestpasswordtestdb2"loadfromaa1.ixfofixfreplaceintotable1COPYNOwithoutprompting"db2"loadfromaa2.ixfofixfreplaceintotable2COPYNOwithoutprompting"db2connectreset
標(biāo)簽: DB2 數(shù)據(jù)庫
主站蜘蛛池模板: 一区二区三区视频在线 | 亚洲男人的天堂网站 | 亚洲电影在线播放 | 99福利视频导航 | 免费av直接看 | 亚洲国产一区二区三区 | 久久99久久99久久 | 久久国产三级 | 91精品久久久 | 亚洲国产精品va在线看黑人 | 成人影音 | 老司机免费视频 | 日韩中文不卡 | 一区二区三区四区五区在线视频 | 91在线观看| 精品日韩在线 | 在线a视频| 91九色porny首页最多播放 | 正在播放亚洲 | 成人久久网 | 久久se精品一区精品二区 | 欧美一级片a | 国产黄色大片在线免费观看 | 伊人久久国产 | 精品美女| 中文字幕高清在线 | 日韩视频在线播放 | 日本免费一区二区三区 | 欧美片网站免费 | 亚洲精品国产电影 | 国产美女久久久 | 亚洲毛片在线 | 成人综合在线视频 | 99re在线视频免费观看 | 精品香蕉一区二区三区 | 日韩高清中文字幕 | 国产探花在线精品一区二区 | 91国内精精品久久久久久婷婷 | 在线观看中文字幕一区二区 | 亚洲精品日韩综合观看成人91 | 国产精品视频在线免费观看 |