| | |
| | | Map<String, String> mapColumnDesc = new HashMap<>(); |
| | | int idx = 0; |
| | | |
| | | list.add("-- \"" + tableName + "\" - \"" + tableDesc + "\"\nDROP TABLE IF EXISTS \"public\".\"" + tableName + "\";\n"); |
| | | list.add("-- " + tableName + " - " + tableDesc + "\nDROP TABLE IF EXISTS \"public\".\"" + tableName + "\";\n"); |
| | | |
| | | // 遍历列,构建sql |
| | | for (Map<String, Object> column : listColumn) { |
| | |
| | | |
| | | mapColumnDesc.put(name, ParameterUtil.dealNullStr(desc)); |
| | | |
| | | sql += "\t\"" + name + "\" " + GenCodeGauss.mysqlType2Gauss(type); |
| | | sql += "\t\"" + name + "\" " + GenCodeGauss.dbType2Gauss(type); |
| | | switch (type) { |
| | | case "char": |
| | | case "varchar": |
| | | case "nvarchar": |
| | | String length = column.get("length").toString(); |
| | | sql += "(" + length + ")"; |
| | | if (Objects.nonNull(column.get("length"))) { |
| | | String length = column.get("length").toString(); |
| | | sql += "(" + length + ")"; |
| | | } |
| | | if ("1".equals(isNullable)) { |
| | | sql += " NULL DEFAULT NULL"; |
| | | } else { |
| | |
| | | } |
| | | sql += "\n"; |
| | | } |
| | | sql += ")\n" + |
| | | ";\n"; |
| | | sql += ");\n"; |
| | | list.add(sql); |
| | | sql = ""; |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | private static String mysqlType2Gauss(String type) { |
| | | private static String dbType2Gauss(String type) { |
| | | String result = ""; |
| | | switch (type) { |
| | | case "char": |
| | |
| | | |
| | | public static List<String> insertAll(List<Map<String, Object>> list, String tableName, Integer onceCount) { |
| | | List<String> result = new ArrayList<>(); |
| | | String insertSql = "INSERT INTO public." + tableName + "(\""; |
| | | String insertSql = "INSERT INTO public.\"" + tableName + "\"(\""; |
| | | List<String> listColumn = new ArrayList<>(); |
| | | for (String column : list.get(0).keySet()) { |
| | | if ("update_time".equalsIgnoreCase(column)) { |
| | | continue; |
| | | } |
| | | listColumn.add(column); |
| | | listColumn.add("\"" + column + "\""); |
| | | } |
| | | insertSql += StringUtil.join(listColumn, "\",\"") + "\") VALUES"; |
| | | |
| | |
| | | } |
| | | return listTable; |
| | | } |
| | | public static List<String> export(Connection connect, String dbSchema) { |
| | | return GenCodeGauss.export(connect, dbSchema, Boolean.TRUE, Boolean.TRUE); |
| | | } |
| | | } |