mysql转postgresql注意事项
- ifnull()和coalesce()
mysql--ifnull() 改pg--coalesce() ps: mysql -- ifnull(a.audit_result, '') pgsql -- coalesce(a.audit_result, '')
- date_format()和to_date()
mysql--date_format() 改pg--to_date(),声明类型 ‘ ::text' ps: //pg数据库中不能使用'%',如 %y-%m-%d to_date(create_time::text, 'yy-mm-dd')
- find_in_set()和any (string_to_array(‘’, ‘,’))
mysql--find_in_set() 改pg--any (string_to_array(some_column, ',')) ps: select t.dept_id from sys_dept t where find_in_set('100', ancestors) select t.dept_id from sys_dept t where '100' = any (string_to_array(ancestors, ','))
- sysdate()和now()
mysql--sysdate() 改pg--now()
- 模糊匹配
// 如果使用 concat参数,pg数据库需配置隐形转换类型 mysql-- like concat('%', #{testitem}, '%') 改pg-- ilike '%'|| #{testitem} ||'%' 或 like concat('%', #{testitem}, '%')
- group_concat()和string_agg()
mysql-- group_concat(t.cname) 改pg-- array_to_string(array_agg(t.cname),',') 或 string_agg(t.cname,',')
- locate()和strpos()
mysql-- locate() 改pg-- strpos()
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论