PostgreSQL 构造用法举例

构造线段,点,线,范围

postgres=# select proname,pg_get_function_arguments(oid) parameter,pg_get_function_result(oid) result,prosrc from pg_proc where prosrc ~ 'construct';
  proname  |                           parameter                            |  result   |       prosrc       
-----------+----------------------------------------------------------------+-----------+--------------------
 lseg      | point, point                                                   | lseg      | lseg_construct
 point     | double precision, double precision                             | point     | construct_point
 line      | point, point                                                   | line      | line_construct_pp
 int4range | integer, integer                                               | int4range | range_constructor2
 int4range | integer, integer, text                                         | int4range | range_constructor3
 numrange  | numeric, numeric                                               | numrange  | range_constructor2
 numrange  | numeric, numeric, text                                         | numrange  | range_constructor3
 tsrange   | timestamp without time zone, timestamp without time zone       | tsrange   | range_constructor2
 tsrange   | timestamp without time zone, timestamp without time zone, text | tsrange   | range_constructor3
 tstzrange | timestamp with time zone, timestamp with time zone             | tstzrange | range_constructor2
 tstzrange | timestamp with time zone, timestamp with time zone, text       | tstzrange | range_constructor3
 daterange | date, date                                                     | daterange | range_constructor2
 daterange | date, date, text                                               | daterange | range_constructor3
 int8range | bigint, bigint                                                 | int8range | range_constructor2
 int8range | bigint, bigint, text                                           | int8range | range_constructor3
(15 rows)

构造数组

postgres=# select array[1,2,3];
  array  
---------
 {1,2,3}
(1 row)

构造record

postgres=# select row(1,2,'ab');
   row    
----------
 (1,2,ab)
(1 row)

构造表

postgres=# select * from ( values (1,2,'2014-01-01'),(1,2,'2014-01-01'),(1,2,'2014-01-01') ) as t(c1,c2,c3);
 c1 | c2 |     c3     
----+----+------------
  1 |  2 | 2014-01-01
  1 |  2 | 2014-01-01
  1 |  2 | 2014-01-01
(3 rows)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值