当前位置: 代码网 > it编程>数据库>Mysql > Mysql转PostgreSQL注意事项及说明

Mysql转PostgreSQL注意事项及说明

2024年11月25日 Mysql 我要评论
mysql转postgresql注意事项- ifnull()和coalesce()mysql--ifnull()改pg--coalesce()ps:mysql -- ifnull(a.audit_re

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()

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com