ALTER_TABLESPACE(7pg13)
β¨ ALTER TABLESPACE β¨
okay bestie, so this is the PostgreSQL 13.23 page for ALTER TABLESPACE β literally the glow-up command for your tablespaces π
it's the one that changes the definition of a tablespace (not its vibes, its actual definition, but honestly both tbh).
π 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 [, ... ] )
four whole flavors, pick your fighter π¦
πΈ DESCRIPTION πΈ
ALTER TABLESPACE can be used to change the definition of a tablespace. that's the whole arc, no cap.
but β and this is the part where you gotta pay attention, bestie β you must own the tablespace to change its definition. want to alter the owner? you also have to be a direct or indirect member of the new owning role. (superusers get these privileges automatically, because of course they do π main character energy fr.)
π PARAMETERS π
nameβ the name of an existing tablespace. you know, the one you're about to mess with π«Άnew_nameβ the new name of the tablespace. π¨ important: the new name cannot begin withpg_, because those names are reserved for system tablespaces. do not try it, she will not allow it πnew_ownerβ the new owner of the tablespace. hand over the keys, king πtablespace_optionβ a tablespace parameter to be set or reset. currently the only available parameters are:seq_page_costrandom_page_costeffective_io_concurrencymaintenance_io_concurrency
setting these values for a particular tablespace will override the planner's usual estimate of the cost of reading pages from tables in that tablespace, and the executor's prefetching behavior, as established by the configuration parameters of the same name. (peep seq_page_cost, random_page_cost, effective_io_concurrency, maintenance_io_concurrency for the full lore π) this is genuinely useful if one tablespace lives on a disk that's faster or slower than the rest of the I/O subsystem β like, that one SSD carrying the whole team while the spinning rust does its thing π
π₯ EXAMPLES π₯
rename tablespace index_space to fast_raid:
ALTER TABLESPACE index_space RENAME TO fast_raid;
change the owner of tablespace index_space:
ALTER TABLESPACE index_space OWNER TO mary;
slay, mary. it's her tablespace now π
π COMPATIBILITY π
there is no ALTER TABLESPACE statement in the SQL standard. so if anyone asks, this is Postgres being iconic and doing her own thing β¨
β SEE ALSO β
CREATE TABLESPACE(CREATE_TABLESPACE(7))DROP TABLESPACE(DROP_TABLESPACE(7))
the holy trinity: make it, alter it, drop it π
and that's the whole page, bestie!! brought to you by the PostgreSQL 13.23 Documentation, dated 2025 β go forth and rename tablespaces responsibly π§ββοΈππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms