您现在的位置是:网站首页> 编程资料编程资料
postgresql coalesce函数数据转换方式_PostgreSQL_
2023-05-27
405人已围观
简介 postgresql coalesce函数数据转换方式_PostgreSQL_
oracle 的NVL(col,0)是判断如果col字段为空的时候赋值0,同样的postgresql中的函数就是coalesce,用法是一样的
SELECT coalesce(collect_result,value) as collect_result FROM collect
数据库中如果查询的字段collect_result为空那么赋值value给collect_result。
补充:postgresql coalesce字段为空时赋一个固定值,等同oracle的nvl
字段为空时赋一个固定值
select coalesce(column_name,0) from table_name;
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。如有错误或未考虑完全的地方,望不吝赐教。
您可能感兴趣的文章:
相关内容
- postgresql 中的COALESCE()函数使用小技巧_PostgreSQL_
- postgresql 实现修改jsonb字段中的某一个值_PostgreSQL_
- postgresql 实现将字段为空的值替换为指定值_PostgreSQL_
- PostgreSQL 禁用全表扫描的实现_PostgreSQL_
- 解决PostgreSQL Array使用中的一些小问题_PostgreSQL_
- postgresql 中的 like 查询优化方案_PostgreSQL_
- 解析PostgreSQL中Oid和Relfilenode的映射问题_PostgreSQL_
- PostgreSQL regexp_matches替换like模糊查询的操作_PostgreSQL_
- postgresql 实现replace into功能的代码_PostgreSQL_
- postgresql 替换空格 换行和回车的操作_PostgreSQL_
