Вопрос

How can I write a query to check if a PostgreSQL (10.x) table is a temporary table?

I looked at the pg_class system table, but couldn't find any column about whether the relation is temporary.

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)
Это было полезно?

Решение

Quote from the manual

relpersistence: p = permanent table, u = unlogged table, t = temporary table

Лицензировано под: CC-BY-SA с атрибуция
Не связан с dba.stackexchange
scroll top