当前位置:网站首页>postgresql没有nvl的解决办法,postgresql查询所有的表
postgresql没有nvl的解决办法,postgresql查询所有的表
2022-07-23 09:59:00 【胡八一】
postgresql没有nvl的解决办法
oracle 的NVL(col,0)是判断如果col字段为空的时候赋值0。
postgresql里也有类似的方法COALESCE,
COALESCE函数是返回参数中的第一个非null的值,它要求参数中至少有一个是非null的,如果参数都是null会报错,如下
SELECT coalesce(collect_result,0) as collect_result FROM collect
select COALESCE(null,null); //报错
select COALESCE(null,null,now()::varchar,''); //结果会得到当前的时间
select COALESCE(null,null,'',now()::varchar); //结果会得到''
//可以和其他函数配合来实现一些复杂点的功能:查询学生姓名,如果学生名字为null或''则显示“姓名为空”
select case when coalesce(name,'') = '' then '姓名为空' else name end from student;
postgresql查询所有的表
select * from pg_tables where schemaname = '模式名' order by tablename asc;
边栏推荐
- 转自玉溪信息公开:mRNA新冠疫苗、九洲马破伤风免疫球蛋白等产品有望年内上市。
- String function of MySQL function summary
- 如何加速矩阵乘法——优化GEMM (CPU单线程篇)
- Postgresql快照优化Globalvis新体系分析(性能大幅增强)
- OpenCV计算外包矩形
- Educational Codeforces Round 132 (Rated for Div. 2) D. Rorororobot
- pytorch opencv pil图像预处理比较
- 百度工程师眼中的云原生可观测性追踪技术
- raid homes and plunder houses!
- [test platform development] 20. Complete the function of sending interface request on the edit page
猜你喜欢
随机推荐
深度学习单图三维人脸重建
Live classroom system 03 supplement model class and entity
@FeignClient使用詳細教程(圖解)
c语言:深度刨析const关键字
[untitled] test [untitled] test
【机器学习基础】无监督学习(5)——生成模型
【启发式分治】启发式合并的逆思想
[test platform development] 20. Complete the function of sending interface request on the edit page
QT document reading notes audio example analysis
Head pose estimation principle and visualization_ Loveliuzz's blog - Programmer's Homestead_ Head posture estimation
Qu'est - ce que le codage par titre?
Live classroom system 02 build project environment
The accuracy of digital addition
【7.16】代码源 -【数组划分】【拆拆】【选数2】【最大公约数】
Prometheus入门使用(三)
Regular expression common syntax parsing
What methods are called behind the use of objects
Multiple backpacks!
如何加速矩阵乘法——优化GEMM (CPU单线程篇)
The self-developed data products have been iterated for more than a year. Why not buy third-party commercial data platform products?









