CREATE UNLOGGED TABLE IF NOT EXISTS <tablename>
How can I first check if the desired table is created UNLOGGED
, and if not alter the table accordingly?
postgres 9.4
CREATE UNLOGGED TABLE IF NOT EXISTS <tablename>
How can I first check if the desired table is created UNLOGGED
, and if not alter the table accordingly?
postgres 9.4
You can check column relpersistence
of table pg_class
;
postgres=# select relpersistence, relname from pg_class where relname like 'foo%'; ┌────────────────┬─────────┐ │ relpersistence │ relname │ ╞════════════════╪═════════╡ │ p │ foo │ │ p │ foo1 │ │ u │ foo2 │ └────────────────┴─────────┘ (3 rows)
foo2
is unlogged table.