电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 1982 人浏览分享

Oracle 和 Mysql 数据库表字段对比讲解

[复制链接]
1982 0

Oracle 和 Mysql 数据库表字段对比讲解

  1. Oracle select * from user_tab_columns
复制代码


20180608095735315.png

Oracle可以通过User_tab_columns查询相关表结构信息

  1. Mysql select * from information_schema.columns
复制代码


20180608095735321.png

Oracle可以通过information_schema.columns查询相关表结构信息

如果有多张表可将他们带条件查询where table_name in('表名1','表名2')查询最终结果用Excl保存起来

20180608095735327.png

类似这张

接着java用POI写文件流

  1. public Map getExclMap(String templateFilePath){
  2.     文件templateFile =新文件(templateFilePath);
  3.     HSSFWorkbook workBookOut = null;
  4.     Map <string,arraylist> tabMap1 = new HashMap <>();
  5.     尝试{
  6.       FileInputStream inputStream = new FileInputStream(templateFile);
  7.       workBookOut = new HSSFWorkbook(inputStream);
  8.       HSSFSheet sheetOut = workBookOut.getSheetAt(0);
  9.       int rows = sheetOut.getLastRowNum(); //得到Excl最后一行下标
  10. //第一次循环将表名作为关键值
  11.       for(int i = 0; i <= rows; i ++){
  12.         字符串tabNameStr = sheetOut.getRow(i).getCell(1).getStringCellValue();
  13.         tabNameStr = tabNameStr.toUpperCase(); //防止大小写不一致
  14.         tabMap1.put(tabNameStr,new ArrayList());
  15.       }
  16. //第二次循环将字段放值
  17.       for(int i = 0; i <= rows; i ++){
  18.         字符串tabNameStr = sheetOut.getRow(i).getCell(1).getStringCellValue();
  19.         tabNameStr = tabNameStr.toUpperCase();
  20. </string,arraylist>
复制代码

  1. String clumStr = sheetOut.getRow(i).getCell(2).getStringCellValue();
  2. clumStr = clumStr.toUpperCase();
  3. tabMap1.get(tabNameStr).add(clumStr);
  4.   }
  5.     } catch(Exception e){
  6.       e.printStackTrace();
  7.     }
  8.     System.out.println(“templateFilePath = [”+ count +“]”);
  9.     返回tabMap1;
  10.   }
复制代码


比较方法

  1. public static void main(String [] args){
  2.   UtilExcl utilExcl =新的UtilExcl();

  3. 映射an50 = utilExcl.getExclMap(“D:\\ Users \\ User \\ Desktop \\ marClums \\ AN50.xls”); // 65
  4. map ship79 = utilExcl.getExclMap(“D:\\ Users \\ User \\ Desktop \\ marClums \\ ship79.xls”); // 65
  5. String [] tabs = utilExcl.getTabs();
  6. int coun = 0;
  7.   //测试ship79有50没有的表或字段
  8. //循环79键
  9. for(对象键:ship79.keySet()){
  10. //判断是否包含键也就得到了不包含的表名
  11. 如果(an50.containsKey(键)){
  12. ArrayList <string> key50List =(ArrayList <string>)an50.get(key);
  13. ArrayList <string> key79List =(ArrayList <string>)ship79.get(key);
  14. //同第一个循环自行理解
  15. for(int i = 0; i<pre></pre>
  16. <p>最后希望大家喜欢如果是同类型数据库建议通过上面的表大写写sql个人sql写的不是很好</p>
  17. <p>也就不给上面sql方案了</p>
  18. </string></string></string></string>
复制代码






您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

0

粉丝

9021

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.