Skip to content

Instantly share code, notes, and snippets.

@fabriziomello
Created January 8, 2016 02:15
Show Gist options
  • Select an option

  • Save fabriziomello/c3cfcee97e9c2945aa5e to your computer and use it in GitHub Desktop.

Select an option

Save fabriziomello/c3cfcee97e9c2945aa5e to your computer and use it in GitHub Desktop.
ALTER TABLE ... SET LOGGED, SET TABLESPACE ...
fabrizio=# \db+
List of tablespaces
Name | Owner | Location | Access privileges | Options | Size | Description
------------+----------+----------+-------------------+---------+--------+-------------
pg_default | fabrizio | | | | 27 MB |
pg_global | fabrizio | | | | 496 kB |
(2 rows)
fabrizio=# create tablespace tb1 location '/tmp/tablespace';
CREATE TABLESPACE
fabrizio=#
fabrizio=# \db+
List of tablespaces
Name | Owner | Location | Access privileges | Options | Size | Description
------------+----------+-----------------+-------------------+---------+---------+-------------
pg_default | fabrizio | | | | 27 MB |
pg_global | fabrizio | | | | 496 kB |
tb1 | fabrizio | /tmp/tablespace | | | 0 bytes |
(3 rows)
fabrizio=# create unlogged table foo(id serial);
CREATE TABLE
fabrizio=# insert into foo select * from generate_series(1,100);
INSERT 0 100
fabrizio=# \db+
List of tablespaces
Name | Owner | Location | Access privileges | Options | Size | Description
------------+----------+-----------------+-------------------+---------+---------+-------------
pg_default | fabrizio | | | | 27 MB |
pg_global | fabrizio | | | | 496 kB |
tb1 | fabrizio | /tmp/tablespace | | | 0 bytes |
(3 rows)
fabrizio=# alter table foo set logged, set tablespace tb1;
ALTER TABLE
fabrizio=# \db+
List of tablespaces
Name | Owner | Location | Access privileges | Options | Size | Description
------------+----------+-----------------+-------------------+---------+--------+-------------
pg_default | fabrizio | | | | 27 MB |
pg_global | fabrizio | | | | 496 kB |
tb1 | fabrizio | /tmp/tablespace | | | 12 kB |
(3 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment