
greenplum
ProductBug
这个作者很懒,什么都没留下…
展开
-
greenplum 拼接字符转为 json 类型
insert into test select ('{"gender":'||gender||'}')::jsonb from tablealimit 5;原创 2020-06-02 15:27:04 · 750 阅读 · 0 评论 -
greenplum json 字段的插入值格式
1、insert into test(profile) values(’{“a”:“a”}’);2、insert into cdp_test(ren) values(’{“a”:12}’);原创 2020-05-27 20:40:58 · 485 阅读 · 1 评论 -
(greenplum)自定义函数,从数组字段中删除某个元素(亲测可用)
参数解释:taskidArray:你想要从中删除元素的数组字段oneTaskid:你想要删除的那个元素CREATE OR REPLACE function my_array_remove(taskidArray text[],oneTaskid text) returns text[] as $BODY$declare x text;declare new_array text...原创 2019-01-17 14:52:16 · 1369 阅读 · 0 评论 -
在greenplum中自定义数组去重函数(亲测可用)
在greenplum数据库中自定义数组函数(亲测可用)背景:我的A表里面有一个字段叫taskidArray text[],是数组类型,这个字段里面存的是一个一个的taskid。现在我有另一张表B,里面有一个字段叫taskid。现在我要做的是把B表里面的taskid给append到A表里面的taskidArray字段里面去。那如果taskidArray里面已经包含了将要插入的taskid,...原创 2019-01-09 11:38:16 · 1534 阅读 · 0 评论 -
如何在greenplum数据库中查找一周前到当前时间的数据(亲测可用)
查找出最近7天的数据select * from 表名 where time between (select current_timestamp - interval '3 day')and current_timestamp;原创 2019-01-08 17:24:17 · 3035 阅读 · 0 评论 -
如何在greenplum数据库中删除最新时间以外的所有重复记录(亲测可用)
背景:假设一张表有5个字段,其中一个字段为时间字段。表中数据情况为:除时间字段值不同外,其他字段值都相同,现在要把多余的记录删掉,保留最新时间的那一条。insert into table_name_tmp select a.* from table_name a where not exists(select 1 from table_name b where b.member_id...原创 2019-01-08 17:37:15 · 1007 阅读 · 0 评论 -
在greenplum中自定义获取时间数组字段最大值函数。(亲测可用)
CREATE OR REPLACE function maxTime(arr timestamp[]) returns timestamp as $BODY$declare x timestamp;declare min timestamp;begin if arr is null then return null; end if; if array_length...原创 2019-01-09 12:08:02 · 1213 阅读 · 0 评论 -
在Greenplum数据库中查询表的comment(亲测可用)
有的时候需要在Greenplum数据库里面查看某张表的描述信息,就是Comment on table 。废话不多说,直接上代码,亲测可用。with tmp_tab as ( select pc.oid as ooid,pn.nspname,pc.* from pg_class pc left outer join pg_namespace pn ...原创 2019-03-25 12:55:59 · 3647 阅读 · 0 评论