oracle 和 mysql 表字段对比讲解
oracle select * from user_tab_columns
oracle可以通过user_tab_columns查询相关表结构信息
mysql select * from information_schema.columns
oracle可以通过information_schema.columns查询相关表结构信息
如果有多张表可将他们带条件查询where table_name in('表名1','表名2')查询最终结果用excl保存起来
类似这张
接着java用poi写文件流
public map getexclmap(string templatefilepath){
文件templatefile =新文件(templatefilepath);
hssfworkbook workbookout = null;
map tabmap1 = new hashmap <>();
尝试{
fileinputstream inputstream = new fileinputstream(templatefile);
workbookout = new hssfworkbook(inputstream);
hssfsheet sheetout = workbookout.getsheetat(0);
int rows = sheetout.getlastrownum(); //得到excl最后一行下标
//第一次循环将表名作为关键值
for(int i = 0; i <= rows; i ++){
字符串tabnamestr = sheetout.getrow(i).getcell(1).getstringcellvalue();
tabnamestr = tabnamestr.touppercase(); //防止大小写不一致
tabmap1.put(tabnamestr,new arraylist());
}
//第二次循环将字段放值
for(int i = 0; i <= rows; i ++){
字符串tabnamestr = sheetout.getrow(i).getcell(1).getstringcellvalue();
tabnamestr = tabnamestr.touppercase();
string clumstr = sheetout.getrow(i).getcell(2).getstringcellvalue();
clumstr = clumstr.touppercase();
tabmap1.get(tabnamestr).add(clumstr);
}
} catch(exception e){
e.printstacktrace();
}
system.out.println(“templatefilepath = [”+ count +“]”);
返回tabmap1;
}
比较方法
public static void main(string [] args){
utilexcl utilexcl =新的utilexcl();
映射an50 = utilexcl.getexclmap(“d:\\ users \\ user \\ desktop \\ marclums \\ an50.xls”); // 65
map ship79 = utilexcl.getexclmap(“d:\\ users \\ user \\ desktop \\ marclums \\ ship79.xls”); // 65
string [] tabs = utilexcl.gettabs();
int coun = 0;
//测试ship79有50没有的表或字段
//循环79键
for(对象键:ship79.keyset()){
//判断是否包含键也就得到了不包含的表名
如果(an50.containskey(键)){
arraylist key50list =(arraylist )an50.get(key);
arraylist key79list =(arraylist )ship79.get(key);
//同第一个循环自行理解
for(int i = 0; i
最后希望大家喜欢如果是同类型数据库建议通过上面的表大写写sql个人sql写的不是很好
也就不给上面sql方案了
希望与广大网友互动??
点此进行留言吧!