源oracle数据库是GBK字符集,目标库是UTF8字符集,现在需要将源库的一个表空间数据导入到目标库。我的解决方法有点繁琐,首先直接导出源库的表空间
expdp trmuser/trmpass schemas=trmuser DIRECTORY=ORACLEDMP dumpfile=trmpass-$(date +%Y%m%d).dmp;
然后在目标库导入表空间
impdp trmuser/trmpass remap_schema=trmuser:trmuser remap_tablespace=trm_data:trm_data DIRECTORY=ORACLEDMP dumpfile=trmpass-20190109.dmp table_exists_ac
tion=replace parallel=4 logfile=trmuser.log
导入后查看错误日志trmuser.log,然后执行程序,生成源库所要扩字段的SQL语句。
TableObject.java
package com.efounder.sdu.test;
public class TableObject {
// 表名
String tableName;
// 字段名
String columnName;
// 原先最大值
Integer oldMaxSize;
// 现最大值
Integer maxSize;
Integer lineNum;
// 修改字段的sql
String sql;
public Integer getLineNum() {
return lineNum;
}
public void setLineNum(Integer lineNum) {
this.lineNum = lineNum;
}
public String getSql() {
return sql;
}
public void setSql(String sql) {
this.sql = sql;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getColumnName() {
return columnName;
}
public void setColumnName(String columnName) {
this.columnName = columnName;
}
public Integer getMaxSize() {
return maxSize;
}
public void setMaxSize(Integer maxSize) {
this.maxSize = maxSize;
}
public Integer getOldMaxSize() {
return oldMaxSize;
}
public void setOldMaxSize(Integer oldMaxSize) {
this.oldMaxSize = oldMaxSize;
}
}
CWZTTest4.java(根据自己用户表空间信息进行修改)
package com.efounder.sdu.test;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* todo
*
* @author wangxin
* @version 2018/12/22 22:34
*/
public class CWZTTest4 {
public static String SPACE = " ";
public static void main(String[] args) throws Exception {
String format = "yyyy-MM-dd HHmm";
SimpleDateFormat