ALTER_TABLESPACE(7pg17)
β¨ ALTER TABLESPACE π
okay bestie, welcome to the ALTER TABLESPACE page from the PostgreSQL 17.11 docs β this is the one where we β¨change the definition of a tablespaceβ¨ and honestly it's giving "small page, big main character energy" π
πΈ NAME πΈ
ALTER_TABLESPACE β literally just: change the definition of a tablespace π¦
π SYNOPSIS π
ALTER TABLESPACE name RENAME TO new_name
ALTER TABLESPACE name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER TABLESPACE name SET ( tablespace_option = value [, ... ] )
ALTER TABLESPACE name RESET ( tablespace_option [, ... ] )
four whole forms, pick your fighter π
π DESCRIPTION π
So ALTER TABLESPACE can be used to change the definition of a tablespace. That's the whole vibe. Simple. Iconic. No notes. β¨
But listen β there's a permission check, no cap. You must own the tablespace to change the definition of a tablespace. And if you wanna alter the owner, you must also be able to SET ROLE to the new owning role. (Friendly reminder that superusers have these privileges automatically, because of course they do ππ)
π«Ά PARAMETERS π«Ά
nameβ the name of an existing tablespace. Existing, bestie, don't come at it with a made-up one πnew_nameβ the new name of the tablespace.<italic>Important:</italic>the new name cannot begin withpg_, because those names are reserved for system tablespaces. That prefix is not your lane π«πnew_ownerβ the new owner of the tablespace. Slay, transfer of power πtablespace_optionβ a tablespace parameter to be set or reset. Currently, the only available parameters areseq_page_cost,random_page_cost,effective_io_concurrencyandmaintenance_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 (seeseq_page_cost,random_page_cost,effective_io_concurrency,maintenance_io_concurrency). This may be useful if one tablespace is located on a disk which is faster or slower than the remainder of the I/O subsystem. Your one fast SSD among the sad spinning disks? This is for her π₯
π 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;
boom. two examples. both ate. π β¨
β COMPATIBILITY β
There is no ALTER TABLESPACE statement in the SQL standard. So this is very much a PostgreSQL-original-girl situation π
π¦ SEE ALSO π¦
CREATE TABLESPACE(CREATE_TABLESPACE(7))DROP TABLESPACE(DROP_TABLESPACE(7))
the whole tablespace trilogy, go read the other two π§π
and that's the page!! this was PostgreSQL 17.11 documentation, dated 2026, and yes β the manual entry is literally called ALTER TABLESPACE(7) ππ go alter something, bestie, ily, bye π«ΆπΈ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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