随笔分类 - postgresql
摘要:SELECT stage, pln_status FROM project ORDER BY CASE WHEN pln_status = '规划' THEN 1 WHEN pln_status = '初选' THEN 2 WHEN pln_status = '查勘' THEN 3 WHEN pln
阅读全文
摘要:主要是查pg_lock,再结合pg_stat_activity和pg_class,我用的SQL是: select relation::regclass, s.pid, granted, client_hostname, application_name, usename, query from pg
阅读全文
摘要:any 操作符 where expression operator any (subquery) where expression operator some (subquery) 其实any和some在这里是同等效的,子查询的结果集只能是一个字段,左边表达式使用operator对结果集的每一行进行
阅读全文
摘要:type JSON json.RawMessage // Scan scan value into Jsonb, implements sql.Scanner interface func (j *JSON) Scan(value interface{}) error { bytes, ok :=
阅读全文
摘要:PostgreSQL ARRAY_AGG()函数是一个聚合函数,它接受一组值并返回一个数组,其中将输入集中的每个值分配给该数组的元素。 用法: ARRAY_AGG(expression [ORDER BY [sort_expression {ASC | DESC}], [...]) ORDER BY
阅读全文
摘要:1. 问题背景数据表中插入了几条测试数据,后又手动删除,导致后面插入数据的时候报主键冲突: ERROR: duplicate key value violates unique constraint "tableName_pkey" DETAIL: Key (id)=(1) already exis
阅读全文
摘要://postgres.Jsonb 处理 type homeWorkQuestionIds struct { QuestionIDs postgres.Jsonb `json:"question_ids"` } var homeworkRes []homeWorkQuestionIds db.Mode
阅读全文

浙公网安备 33010602011771号