若依集成达梦数据库
1.配置文件
# 数据源配置
driverClassName: dm.jdbc.driver.DmDriver
druid:
master:
url: jdbc:dm://124.223.59.28:5236/SZDBDM?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: SZDBDM
password: 123456789
# PageHelper分页插件
pagehelper:
helperDialect: oracle
supportMethodsArguments: true
params: count=countSql
2.不适配的函数
1.
-- 原函数
replace into
-- 新函数
merge into
2.
-- 原函数
find_in_set(#{deptId}, ancestors)
-- 新函数
instr(','||ancestors||',' , ','|| #{deptId} ||',')
3.Mapper代码修改
1.获取表定义信息,修改GenTableMapper
-- 原代码
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_schema = (select database())
AND table_name NOT LIKE 'QRTZ_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
</if>
<if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
</if>
order by create_time desc
</select>
-- 修改后代码:
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
select so.NAME table_name, st.COMMENT$ table_comment, so.CRTDATE create_time from SYS.SYSOBJECTS so left join SYS.SYSTABLECOMMENTS st on so.NAME = st.TVNAME and st.TABLE_TYPE = 'TABLE' and st.SCHNAME = (select CURR_SCH from V$SESSIONS LIMIT 1)
where so.TYPE$='SCHOBJ' and so.SUBTYPE$='UTAB' and so.PID = -1 and INSTR(so.NAME,'##') = 0 and so.SCHID = (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH from V$SESSIONS LIMIT 1)) and so.NAME NOT LIKE 'QRTZ_%' AND so.NAME NOT LIKE 'gen_%'
and so.NAME NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''">
and lower(so.NAME) like lower(concat('%', #{tableName}, '%'))
</if>
<if test="tableComment != null and tableComment != ''">
and lower(st.COMMENT$) like lower(concat('%', #{tableComment}, '%'))
</if>
order by so.CRTDATE desc
</select>
2.方法selectDbTableListByNames修改:
-- 原代码:
<select id="selectDbTableListByNames" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
and table_name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</select>
-- 修改后代码
<select id="selectDbTableListByNames" resultMap="GenTableResult">
select so.NAME table_name, st.COMMENT$ table_comment, so.CRTDATE create_time from SYS.SYSOBJECTS so left join SYS.SYSTABLECOMMENTS st on so.NAME = st.TVNAME and st.TABLE_TYPE = 'TABLE' and st.SCHNAME = (select CURR_SCH from V$SESSIONS LIMIT 1)
where so.TYPE$='SCHOBJ' and so.SUBTYPE$='UTAB' and so.PID = -1 and INSTR(so.NAME,'##') = 0 and so.SCHID = (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH from V$SESSIONS LIMIT 1)) and so.NAME NOT LIKE 'qrtz_%' and so.NAME NOT LIKE 'gen_%'
and so.NAME in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</select>
3.方法selectDbTableColumnsByName修改
-- 原代码
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk,ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
order by ordinal_position
</select>
-- 修改后代码
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select sc.NAME column_name, (case when sc.INFO2 = 1 then '1' else '0' end) is_pk, sc.COLID sort, scc.COMMENT$ column_comment, (case when sc.INFO2 = 1 then '1' else '0' end) as is_increment, sc.TYPE$ column_type
from SYS.SYSCOLUMNS sc left join SYS.SYSOBJECTS so on sc.ID = so.ID left join SYS.SYSCOLUMNCOMMENTS SCC on sc.NAME = scc.COLNAME and scc.TABLE_TYPE = 'TABLE' and scc.SCHNAME = (select CURR_SCH from V$SESSIONS LIMIT 1) and scc.TVNAME= so.NAME
where so.TYPE$='SCHOBJ' and so.SUBTYPE$='UTAB' and so.PID = -1 and so.SCHID = (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH from V$SESSIONS LIMIT 1)) and so.NAME = #{tableName}
</select>
4.注意事项
1.Mysql是单实例多库的,一个用户可以访问多个数据库,然后数据库写就不用带上数据库名了,达梦单库多实例的,没有多个数据库的概念,需要建多个用户+表空间来对应访问所以需要带表明
2.如果想不带 每个用户有一个默认的同名的模式,访问自己模式下的表、视图等不需要加模式名,访问其他模式下的对象需要加上模式名
达梦数据库与mysql不适配的函数
1.不识别`和“符号
2.convert(),mysql为CONVERT(value, type),达梦为CONVERT(type,value)
3.ON DUPLICATE KEY UPDATE 函数不能使用