ALTER TABLESPACE modifies the definition of an existing tablespace.
Prerequisites
To run ALTER TABLESPACE, you must own the tablespace. To change the owner, you must also be a direct or indirect member of the new owning role. Superusers have these privileges automatically.
Synopsis
ALTER TABLESPACE name RENAME TO new_name
ALTER TABLESPACE name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
ALTER TABLESPACE name SET ( tablespace_option = value [, ... ] )
ALTER TABLESPACE name RESET ( tablespace_option [, ... ] )Parameters
| Parameter | Description |
|---|---|
name | The name of an existing tablespace. |
new_name | The new name for the tablespace. Names beginning with pg_ are reserved for system tablespaces and cannot be used. |
new_owner | The new owner of the tablespace. |
tablespace_option | A tablespace parameter to set or reset. See Tablespace options for available values. |
Tablespace options
The tablespace_option parameter accepts the following values:
| Option | Description |
|---|---|
seq_page_cost | Overrides the planner's estimate of the cost of a sequential page read for tables in this tablespace. |
random_page_cost | Overrides the planner's estimate of the cost of a non-sequential page read for tables in this tablespace. |
effective_io_concurrency | Overrides the executor's prefetching behavior for tables in this tablespace. |
maintenance_io_concurrency | Overrides the executor's prefetching behavior for tables in this tablespace. |
These options are useful when a tablespace resides on a disk that is significantly faster or slower than the rest of the I/O subsystem. The values override the corresponding server-level configuration parameters of the same name.
Examples
Rename a tablespace:
ALTER TABLESPACE index_space RENAME TO fast_raid;Change the owner of a tablespace:
ALTER TABLESPACE index_space OWNER TO mary;