加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql笔记几则

发布时间:2020-12-13 17:28:49 所属栏目:百科 来源:网络整理
导读:1. select count(*) from A,统计所有数据包括null数据,这里会使用到聚合索引,如果判断聚合索引可以加快速度. 2. select count(a) from A,这里统计a列数据,除去null数据,如果select count(1) from a,之类的参数非表A列统 计所有数据. 3. select * from A wher

1. select count(*) from A,统计所有数据包括null数据,这里会使用到聚合索引,如果判断聚合索引可以加快速度.

2. select count(a) from A,这里统计a列数据,除去null数据,如果select count(1) from a,之类的参数非表A列统

计所有数据.


3. select * from A where a = any (array(select b from B))这种比较array和scalar数据,也可以这样做:

select * from A where a = any ((select array(select b from B))::varchar[]) .

或select array(select a from A) <@ Array[1,2,3]

或:select (select array_agg(a) from A) <@ Array[1,3]

array的还原时unnest函数如:select unnest(Array[1,3])

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读