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

PostgreSQL中的数组与Any

发布时间:2020-12-13 17:12:49 所属栏目:百科 来源:网络整理
导读:建立表: CREATE TABLE sal_emp (name text ,pay_by_quarter integer [] ,schedule text [][] ); 插入数据: INSERT INTO sal_emp VALUES ( ' Bill ' ,ARRAY [ 10000,11000,9000,13000 ] ,0); line-height:1.5!important">['meeting','lunch' ] , 'training'

建立表:

CREATE TABLE sal_emp (
name            text,pay_by_quarter  integer[],schedule        text[][]
);

插入数据:

INSERT INTO sal_emp
  VALUES ('Bill',ARRAY[10000,11000,9000,13000],0); line-height:1.5!important">['meeting','lunch'],'training','presentation']]);

Carol20000,25000,25000['breakfast','consulting''meeting',0); line-height:1.5!important">Frank]]);

查看:

pgsql=# SELECT * FROM sal_emp;
 name  |      pay_by_quarter       |                 schedule                  
-------+---------------------------+-------------------------------------------
 Bill  | {10000,11000,0); line-height:1.5!important">9000,0); line-height:1.5!important">13000}  | {{meeting,lunch},{training,presentation}}
 Carol 20000,0); line-height:1.5!important">25000,0); line-height:1.5!important">25000} | {{breakfast,consulting},{meeting,lunch}}
 Frank 10000} 3 rows)

pgsql=# 
用Any来查询:

FROM sal_emp WHERE 10000 = ANY (pay_by_quarter); name 2 rows) pgsql 用ALL来查询:

ALL (pay_by_quarter); name | schedule -----+---------------------------+---------------------------------------- Frank 1 row) pgsql 用下标来查询:

9000 = pay_by_quarter3]; name | pay_by_quarter ----+--------------------------+------------------------------------------- Bill 13000}

(编辑:李大同)

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

    推荐文章
      热点阅读