Mysql轉(zhuǎn)PostgreSQL注意事項及說明
更新時間:2024年10月31日 09:27:09 作者:佛說"獨"
這篇文章主要介紹了Mysql轉(zhuǎn)PostgreSQL注意事項及說明,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
Mysql轉(zhuǎn)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數(shù)據(jù)庫中不能使用'%',如 %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參數(shù),pg數(shù)據(jù)庫需配置隱形轉(zhuǎn)換類型 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()
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
MySql采用GROUP_CONCAT合并多條數(shù)據(jù)顯示的方法
這篇文章主要介紹了MySql采用GROUP_CONCAT合并多條數(shù)據(jù)顯示的方法,是MySQL數(shù)據(jù)庫程序設(shè)計中常見的實用技巧,需要的朋友可以參考下2014-10-10MySQL中時區(qū)參數(shù)time_zone解讀
MySQL時區(qū)參數(shù)time_zone用于控制系統(tǒng)函數(shù)和字段的DEFAULT CURRENT_TIMESTAMP屬性,修改時區(qū)可能會影響timestamp類型的值,建議在MySQL配置文件中設(shè)置時區(qū)參數(shù),以確保高并發(fā)時的性能,在業(yè)務(wù)中盡量使用datetime類型來存儲時間,因為其時間上限比TIMESTAMP更遠2025-01-01