PostgreSQL数据类型转换需要使用语法

alter table tbname alter column fieldname type date_type

遇到需要转换为特殊类型如DATE、BOOL需要使用using子句

--转换为date类型
alter table tbname alter column fieldname type date using cast(fieldname as date)

--转换为bool类型
ALTER TABLE tbname
ALTER COLUMN a TYPE boolean
USING CASE a
WHEN 'ano' THEN true
ELSE false END;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-12-05
  • 2022-12-23
  • 2021-05-26
猜你喜欢
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案