ALTER_TABLESPACE(7pg14)
π ALTER TABLESPACE π
ok so this is the ALTER TABLESPACE page from the PostgreSQL 14.24 Documentation β yes, the whole manual, bestie, and we're gonna get through it together π«Ά
β¨ 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 [, ... ] )
look at her. four whole moods. pick one π
πΈ DESCRIPTION πΈ
ALTER TABLESPACE is literally the glow-up command for a tablespace β you use it to change the definition of a tablespace. that's it, that's the vibe.
but listen, there's a gate πͺ you must own the tablespace to change the definition of a tablespace. and if you're trying to alter the owner? you also have to be a direct or indirect member of the new owning role. (and yeah, superusers have these privileges automatically β main character energy, no cap π)
π PARAMETERS π
nameβ the name of an existing tablespace. the one you're messing with.new_nameβ the new name of the tablespace. heads up though: the new name cannot begin withpg_, because those names are reserved for system tablespaces. don't even try it πnew_ownerβ the new owner of the tablespace. hand her over π«Άtablespace_optionβ a tablespace parameter to be set or reset. rn 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. like, one disk is a sports car and the rest are shopping carts? tell the planner ποΈπ¨
π₯ 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;
both iconic. both valid. go off β¨
π COMPATIBILITY π
there is no ALTER TABLESPACE statement in the SQL standard. so if some other database is acting like this is normal β it's not, we're built different π
π SEE ALSO π
CREATE TABLESPACE(CREATE_TABLESPACE(7))DROP TABLESPACE(DROP_TABLESPACE(7))
k that's the whole page, you ate that π this was PostgreSQL 14.24, dated 2026, and it's the ALTER TABLESPACE(7) manual page β mwah, love u, go rename something ππ§
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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