Postgresql

如何檢查 PostgreSQL 表是否是臨時的?

  • March 22, 2018

如何編寫查詢來檢查 PostgreSQL (10.x) 表是否為臨時表?

我查看了pg_class系統表,但找不到任何關於關係是否是臨時的列。

SELECT * FROM pg_class WHERE False;
relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasindex | relisshared | relpersistence | relkind | relnatts | relchecks | relhasoids | relhaspkey | relhasrules | relhastriggers | relhassubclass | relrowsecurity | relforcerowsecurity | relispopulated | relreplident | relispartition | relfrozenxid | relminmxid | relacl | reloptions | relpartbound 
---------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-------------+----------------+---------+----------+-----------+------------+------------+-------------+----------------+----------------+----------------+---------------------+----------------+--------------+----------------+--------------+------------+--------+------------+--------------
(0 rows)

從手冊中引用

relpersistence:p = 永久表,u = 未記錄表,t = 臨時表

引用自:https://dba.stackexchange.com/questions/202057