首先了解几个达梦表结构相关视图
select * from USER_TAB_COMMENTS; --表注释
select * from user_tab_columns; --表中的字段
select * from user_cons_columns; --字段与限制关联关系
select * from user_constraints; --限制描述
select * from user_col_comments; --字段注释
已经将若依代码生成器所属的表结构查询语句修改为达梦语法,直接将如下xml文件的sql替换即可
SQL内容替换
ruoyi-generator\src\main\resources\mapper\generator\GenTableColumnMapper.xml
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select tabcol.column_name,
case when nullable='N' and cons.CONSTRAINT_TYPE!='P' then 1 else null end is_required,
case when cons.CONSTRAINT_TYPE='P' then '1' else '0' end is_pk,
tabcol.COLUMN_ID sort,
colcom.COMMENTS column_comment,
case when ai.COL_NAME is null then '0' else '1' end is_increment,
tabcol.DATA_TYPE
from user_tab_columns tabcol
left join user_cons_columns concol on tabcol.column_name=concol.column_name and concol.TABLE_NAME=tabcol.TABLE_NAME
left join user_constraints cons on cons.CONSTRAINT_NAME=concol.CONSTRAINT_NAME
left join user_col_comments colcom on colcom.TABLE_NAME=tabcol.TABLE_NAME and colcom.COLUMN_NAME=tabcol.COLUMN_NAME
left join (select b.table_name,a.name COL_NAME
from SYS.SYSCOLUMNS a,all_tables b,sys.sysobjects c where a.INFO2 <![CDATA[ & ]]> 0x01 = 0x01
and a.id=c.id and c.name= b.table_name) ai on ai.TABLE_NAME=tabcol.TABLE_NAME and ai.COL_NAME=tabcol.COLUMN_NAME
where tabcol.table_name= #{tableName}
order by tabcol.COLUMN_ID
</select>
ruoyi-generator\src\main\resources\mapper\generator\GenTableMapper.xml
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
select table_name, comments table_comment from USER_TAB_COMMENTS
where 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(comments) like lower(concat('%', #{tableComment}, '%'))
</if>
order by table_name desc
</select>
<select id="selectDbTableListByNames" resultMap="GenTableResult">
select table_name, comments table_comment from USER_TAB_COMMENTS
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%'
and table_name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</select>
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
select table_name,comments table_comment from USER_TAB_COMMENTS
where comments <![CDATA[ <> ]]> ''
and table_name = #{tableName}
</select>