天天看點

PostgreSQL 中繼資料庫講解 - 對象(表、索引、函數、序列、視圖...)在哪裡、如何識别、如何求對象定義

PostgreSQL , pg_stat , 實時品質監控

PostgreSQL中,所有對象的定義都在中繼資料庫中,詳見

<a href="https://www.postgresql.org/docs/10/static/catalogs.html">https://www.postgresql.org/docs/10/static/catalogs.html</a>

除了中繼資料庫,還有一些管理函數,如下

<a href="https://www.postgresql.org/docs/10/static/functions-admin.html">https://www.postgresql.org/docs/10/static/functions-admin.html</a>

下面簡單介紹一下中繼資料庫的使用。

1、識别臨時表、UNLOGGED TABLE、臨時表

pg_class 的relpersistence用于識别表是什麼表(正常表、不記日志表、臨時表)。 relkind用于識别是什麼對象類别(表、索引、序列、切片、視圖、物化視圖、複合類型、外部表、分區表)。

pg_class.relstorage 用于區分是什麼存儲

pg_proc

pg_database

pg_tablespace

pg_namespace

pg_roles

pg_am

使用這些函數接口,可以獲得對應對象的定義。

例子