开启mysql兼容
-
在postgresql.conf文件中增加compatible_db = mysql;开启mysql兼容模式;
-
执行重载命令pg_ctl reload生效参数;
-
登录数据库执行show compatible_db;来查看参数是否生效。
增加类型转换
查看类型text的转换规则:
select castsource::regtype,casttarget::regtype,castcontext,castfunc from pg_cast where castsource='text'::regtype;
瀚高数据库数据类型之间有3种转换,隐式转换,赋值转换,显式转换;三种方式分别对应 i(implicit),a(assignment),e(explicit)。
修改转换规则的类型:
update pg_cast set castcontext='i' where castsource = 'text'::regtype and casttarget='timestamptz'::regtype;
创建用于类型转换的函数:
create or replace function cast_varchar_to_timestamp(varchar) returns timestamptz as $$
select to_timestam