正在阅读:实例解析IBM DB2的数据复制、迁移方法实例解析IBM DB2的数据复制、迁移方法

2007-01-30 14:29 出处: 作者:谢道多 责任编辑:huyuanbing

 

  附录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

键盘也能翻页,试试“← →”键

为您推荐

加载更多
加载更多
加载更多
加载更多
加载更多
加载更多
加载更多
加载更多
加载更多

服务器论坛帖子排行

最高点击 最高回复 最新
最新资讯离线随时看 聊天吐槽赢奖品