Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply PostgreSQL UNLOGGED feature to an existing table?

Tags:

postgresql

Can I ALTER an existing table to be UNLOGGED?

like image 873
alfonx Avatar asked Oct 29 '11 11:10

alfonx


People also ask

What is a Postgres unlogged table?

Unlogged tables is a PostgreSQL feature that can be used effectively to optimize bulk inserts. PostgreSQL uses Write-Ahead Logging (WAL). It provides atomicity and durability, by default. Atomicity, consistency, isolation, and durability make up the ACID properties.

How do I add a column to an existing table in PostgreSQL?

Syntax. The syntax to add a column in a table in PostgreSQL (using the ALTER TABLE statement) is: ALTER TABLE table_name ADD new_column_name column_definition; table_name.

How do I create a global temporary table in PostgreSQL?

The temporary table must be created by each session that uses it and the lifetime of the rows are either commit or session based exactly like it is with the GTT. PostgreSQL has also an additional clause ON COMMIT DROP that automatically drops the temporary table at the end of a transaction.


1 Answers

PostgreSQL 9.5+ allows setting an existing table as LOGGED / UNLOGGED with the ALTER TABLE command... detailed better here.

For e.g. 
ALTER TABLE table_test SET LOGGED;
ALTER TABLE table_test SET UNLOGGED;
like image 174
Robins Tharakan Avatar answered Oct 04 '22 21:10

Robins Tharakan