迁移注意点:
时间函数兼容
str_to_date -> to_date
date_format -> to_char
now()->sysdate
时间格式化:
‘%Y-%m-%d %H:%i:%s’ -> ‘yyyy-mm-dd hh24:mi:ss’
https://www.cnblogs.com/ladyM/p/8378548.html
分页兼容
limit -> rownum
https://blog.csdn.net/use_admin/article/details/83622414
# mysql
select * from tablename
where xxx = xx
order by xxx desc
limit #{startPage}, #{count}
# oracle
select * from (
select tt.*, ROWNUM as rowno from (
select * from tablename
where xxx = xx
order by xxx desc
) tt
where ROWNUM <= #{startPage} + #{count}) table_alias
where table_alias.rowno > #{startPage}
关键字字段查询不支持` `,要大写并加" "
默认current_timestamp类型的字段也需要显式赋值
字符串拼接函数concat用法区别
oracle 三个字段及以上用concat拼接需要嵌套两个concat:
#mysql
select concat('%', 'test’, '%’)
#oracle 不支持mysql多参数用法
select concat(concat('%', 'test’), '%’)
https://www.cnblogs.com/sunchunmei/p/12169964.html
<if test="item.name != null and item.name != ''>
<selectKey keyProperty="id" resultType="java.lang.Integer" order="BEFORE">
select MCC_XXX_SEQUENCE.nextval from dual
</selectKey>
也可以在insert语句直接使用
insert into table_name (id,xxx) values (MCC_XXX_SEQUENCE.nextval, #{xxx});
<!-- mysql中为 open="" close=";" -->
<foreach collection="batchUpdateParams" index="index" item="item" separator=";" open="begin" close=";end;">
update table_name
<set>
<if test="...">...</if>
</set>
where ...
</foreach>
mysql:
#{column_name}
oracle:
#{column_name, jdbcType=VARCHAR}
select level,resource,date,number
以上字段作为表字段时sql中需要转大写加双引号处理:
select "LEVEL","RESOURCE","DATE","NUMBER"