支持达梦数据库

This commit is contained in:
SanLi
2020-09-18 14:21:34 +08:00
parent a622bdd006
commit c3167e3f05

View File

@@ -54,57 +54,58 @@ import dm.jdbc.driver.DmdbConnection;
*/
@SuppressWarnings("serial")
public class DmDataBaseQuery extends AbstractDatabaseQuery {
private ConcurrentMap<String, List<DmTableModel>> tablesMap = new ConcurrentHashMap<>();
private static String DM_QUERY_TABLE_SQL = ""
+ "select "
+ " ut.table_name TABLE_NAME, "
+ " utc.comments COMMENTS "
+ "from "
+ " user_tables ut "
+ "left join USER_TAB_COMMENTS utc "
+ "on "
+ " ut.table_name=utc.table_name ";
private final ConcurrentMap<String, List<DmTableModel>> tablesMap = new ConcurrentHashMap<>();
private static final String DM_QUERY_TABLE_SQL = ""
+ "select "
+ " ut.table_name TABLE_NAME, "
+ " utc.comments COMMENTS "
+ "from "
+ " user_tables ut "
+ "left join USER_TAB_COMMENTS utc "
+ "on "
+ " ut.table_name=utc.table_name ";
private static String DM_QUERY_COLUMNS_SQL = "" + "select "
+ " ut.table_name TABLE_NAME , "
+ " uc.column_name COLUMN_NAME , "
//+ " case uc.data_type when 'INT' then uc.data_type when 'CLOB' then uc.data_type when 'BLOB' then uc.data_type when 'INTEGER' then uc.data_type else concat(concat(concat(uc.data_type, '('), uc.data_length), ')') end case AS COLUMN_TYPE , "
+ " case uc.data_type when 'CLOB' then uc.data_type when 'BLOB' then uc.data_type else concat(concat(concat(uc.data_type, '('), uc.data_length), ')') end case AS COLUMN_TYPE , "
+ " uc.data_length COLUMN_LENGTH , "
+ " uc.DATA_PRECISION DATA_PRECISION, "
+ " uc.DATA_SCALE DECIMAL_DIGITS, "
+ " case uc.NULLABLE when 'Y' then '1' else '0' end case NULLABLE,"
+ " uc.DATA_DEFAULT COLUMN_DEF, "
+ " ucc.comments REMARKS "
+ "from "
+ " user_tables ut "
+ "left join USER_TAB_COMMENTS utc "
+ "on "
+ " ut.table_name=utc.table_name "
+ "left join user_tab_columns uc "
+ "on "
+ " ut.table_name=uc.table_name "
+ "left join user_col_comments ucc "
+ "on "
+ " uc.table_name =ucc.table_name "
+ " and uc.column_name=ucc.column_name "
+ "where 1=1 ";
private static final String DM_QUERY_COLUMNS_SQL = ""
+ "select "
+ " ut.table_name TABLE_NAME , "
+ " uc.column_name COLUMN_NAME , "
//+ " case uc.data_type when 'INT' then uc.data_type when 'CLOB' then uc.data_type when 'BLOB' then uc.data_type when 'INTEGER' then uc.data_type else concat(concat(concat(uc.data_type, '('), uc.data_length), ')') end case AS COLUMN_TYPE , "
+ " case uc.data_type when 'CLOB' then uc.data_type when 'BLOB' then uc.data_type else concat(concat(concat(uc.data_type, '('), uc.data_length), ')') end case AS COLUMN_TYPE , "
+ " uc.data_length COLUMN_LENGTH , "
+ " uc.DATA_PRECISION DATA_PRECISION, "
+ " uc.DATA_SCALE DECIMAL_DIGITS, "
+ " case uc.NULLABLE when 'Y' then '1' else '0' end case NULLABLE,"
+ " uc.DATA_DEFAULT COLUMN_DEF, "
+ " ucc.comments REMARKS "
+ "from "
+ " user_tables ut "
+ "left join USER_TAB_COMMENTS utc "
+ "on "
+ " ut.table_name=utc.table_name "
+ "left join user_tab_columns uc "
+ "on "
+ " ut.table_name=uc.table_name "
+ "left join user_col_comments ucc "
+ "on "
+ " uc.table_name =ucc.table_name "
+ " and uc.column_name=ucc.column_name "
+ "where 1=1 ";
private static String DM_QUERY_PK_SQL = "" + "SELECT "
+ "C.OWNER AS TABLE_SCHEM, "
+ "C.TABLE_NAME , "
+ "C.COLUMN_NAME , "
+ "C.POSITION AS KEY_SEQ , "
+ "C.CONSTRAINT_NAME AS PK_NAME "
+ "FROM "
+ " ALL_CONS_COLUMNS C, "
+ " ALL_CONSTRAINTS K "
+ "WHERE "
+ " K.CONSTRAINT_TYPE = 'P' "
+ " AND K.OWNER = '%s' "
+ " AND K.CONSTRAINT_NAME = C.CONSTRAINT_NAME "
+ " AND K.TABLE_NAME = C.TABLE_NAME "
+ " AND K.OWNER = C.OWNER ";
private static final String DM_QUERY_PK_SQL = "" + "SELECT "
+ "C.OWNER AS TABLE_SCHEM, "
+ "C.TABLE_NAME , "
+ "C.COLUMN_NAME , "
+ "C.POSITION AS KEY_SEQ , "
+ "C.CONSTRAINT_NAME AS PK_NAME "
+ "FROM "
+ " ALL_CONS_COLUMNS C, "
+ " ALL_CONSTRAINTS K "
+ "WHERE "
+ " K.CONSTRAINT_TYPE = 'P' "
+ " AND K.OWNER = '%s' "
+ " AND K.CONSTRAINT_NAME = C.CONSTRAINT_NAME "
+ " AND K.TABLE_NAME = C.TABLE_NAME "
+ " AND K.OWNER = C.OWNER ";
/**
* 构造函数