A.F.N
A.F.N

Reputation: 198

Altering tablespace for partitioned table in Postgres

In my database i have a partitioned table with name 'record_partitioned' on PostgreSQL 11.2. i want to change its tablespace to a new tablespace 'fast_ssd' so all new dervied tables from this table be in 'fast_ssd' tablespace.

when i try to alter tablespace to 'fast_ssd'.

alter table record_partitioned set tablespace fast_ssd;

i see:

ALTER TABLE

but it seems nothing happened! i check tablespace like this:

SELECT tablespace,tablename FROM pg_tables where tablename='record_partitioned';

and output is:

 tablespace |     tablename
------------+--------------------
            | record_partitioned

tablespace does not change.

Upvotes: 1

Views: 2192

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 247545

There is no way to do this for a partitioned table. You'll have to add an explicit TABLESPACE clause whenever you create a partition.

An alternative is to set the default_tablespace parameter, but that would affect all other tables too.

Upvotes: 1

Related Questions