11.PG表之pg_class和pg_stats
1. pg_class表
postgres=# \d pg_class Table "pg_catalog.pg_class" Column | Type | Collation | Nullable | Default ---------------------+--------------+-----------+----------+--------- oid | oid | | not null | 行标识符号 relname | name | | not null | 表,索引、视图等名字 relnamespace | oid | | not null | 包含该关系的名字空间oid reltype | oid | | not null | reloftype | oid | | not null | relowner | oid | | not null | relam | oid | | not null | relfilenode | oid | | not null | reltablespace | oid | | not null | relpages | integer | | not null | reltuples | real | | not null | relallvisible | integer | | not null | reltoastrelid | oid | | not null | relhasindex | boolean | | not null | relisshared | boolean | | not null | relpersistence | "char" | | not null | relkind | "char" | | not null | relnatts | smallint | | not null | relchecks | smallint | | not null | relhasrules | boolean | | not null | relhastriggers | boolean | | not null | relhassubclass | boolean | | not null | relrowsecurity | boolean | | not null | relforcerowsecurity | boolean | | not null | relispopulated | boolean | | not null | relreplident | "char" | | not null | relispartition | boolean | | not null | relrewrite | oid | | not null | relfrozenxid | xid | | not null | relminmxid | xid | | not null | relacl | aclitem[] | | | reloptions | text[] | C | | relpartbound | pg_node_tree | C | | Indexes: "pg_class_oid_index" PRIMARY KEY, btree (oid) "pg_class_relname_nsp_index" UNIQUE CONSTRAINT, btree (relname, relnamespace) "pg_class_tblspc_relfilenode_index" btree (reltablespace, relfilenode)
2.pg_stats
postgres=# \d pg_stats View "pg_catalog.pg_stats" Column | Type | Collation | Nullable | Default ------------------------+----------+-----------+----------+--------- schemaname | name | | | 表的模式名 tablename | name | | | 表的名称 attname | name | | | 列名 inherited | boolean | | | 如果为真,表示此行包括继承子列,不仅仅是指定表中的值 null_frac | real | | | 为空的比例 avg_width | integer | | | 列的条目的平均字节宽度 n_distinct | real | | | -1表示该列中无重复值,小于1,表示有重复值 most_common_vals | anyarray | | | 列中最常用值的一个列表(如果没有任何一个值看起来比其它更常用,此列为空) most_common_freqs | real[] | | | 最常用值的频率列表,即每一个常用值的出现次数除以总数(如果most_common_vals为空,则此列为空) histogram_bounds | anyarray | | | correlation | real | | | most_common_elems | anyarray | | | most_common_elem_freqs | real[] | | | elem_count_histogram | real[] | | |