PostgreSQL
燕返zmzx
这个作者很懒,什么都没留下…
展开
-
postgreSQL 数组ZIP函数
需求 CREATE OR REPLACE FUNCTION “bi”.“zip”(“array1” anyarray, “array2” anyarray) RETURNS “pg_catalog”.“anyarray” AS $BODY$ SELECT ARRAY_AGG(ARRAY[a,b]) FROM unnest(array1,array2) x(a,b); $BODY$ LANGUAGE sql VOLATILE COST 100 版本PostgreSQL 9.4及以上 ...原创 2021-04-08 10:22:14 · 214 阅读 · 0 评论 -
PostgreSQL自增列
` CREATE TABLE aaa( – pg10新特性, id int generated always as identity (cache 100 START WITH 1 INCREMENT BY 1) primary key , id2 serial8, c1 varchar(8) ) INSERT INTO aaa(c1) values(‘第一行’); ALTER TABLE aaa ADD COLUMN c2 int; – 多列共用自增 ALTER TABLE aaa ALTER COLU原创 2020-12-17 17:44:55 · 622 阅读 · 0 评论 -
Postgresql通过查询进行更新
转自:https://bbs.csdn.net/topics/392389383 UPDATE tb1 SET score = COALESCE( b.scorea,0) from tb1 a left join tb2 b on a.ids=b.ida where a.ids = tb1.ids;原创 2019-03-26 19:08:12 · 4258 阅读 · 0 评论 -
查询PostgreSQL库中所有表的表结构信息SQL
select (select relname as comment from pg_class where oid=a.attrelid) as table_name, row_number() over(partition by (select relname as comment from pg_class where oid=a.attrelid) order by a.attnum)...原创 2019-06-20 17:30:01 · 6438 阅读 · 0 评论 -
PostgreSQL的generate_series()函数使用技巧
SELECT generate_series(1,12) AS month; SELECT generate_series(1,12,1) AS month; SELECT generate_series(‘2020-01-01’::DATE,‘2020-12-31’::DATE,‘1 month’::INTERVAL) AS first_of_month;原创 2020-12-15 10:44:56 · 1763 阅读 · 0 评论