[4] PostgreSQL 语法零散总结

Comment 为 pg 数据库的表和列添加注释

  1. 添加表注释
1
COMMENT ON TABLE "public".t1 IS '表注释内容';   
  1. 查看注释
1
select description from pg_description join pg_class on pg_description.objoid = pg_class.oid where relname = 't1';

注释存储在 pg_description 表的 description 字段中,用来查找的每张表的 objoid 存储在 pg_class 中。

  1. 添加列注释
1
2
create table t1(id int primary key, cc char(10));
comment on column t1.id is '列注释内容';
  1. Postgres 查重复数据
1
select * from pg_public_tree_node ou where (select count(*) from pg_public_tree_node inr where inr.id = ou.id) > 1;
Licensed under CC BY-NC-SA 4.0
使用 Hugo 构建
主题 StackJimmy 设计