{"Entry":{"collection":"guc","key":"default_tablespace","name":"default_tablespace","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Client Connection Defaults / Statement Behavior","category_zh":"","changed_in":["18"],"changes":[{"documentation_changed":false,"fields":{},"from":"7.4","status":"added","to":"8.0"},{"documentation_changed":true,"fields":{},"from":"8.0","status":"changed","to":"8.1"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.3","status":"changed","to":"8.4"},{"documentation_changed":true,"fields":{},"from":"9.0","status":"changed","to":"9.1"},{"documentation_changed":true,"fields":{},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"},{"documentation_changed":false,"fields":{"extra_desc":{"from":"An empty string selects the database's default tablespace.","to":"An empty string means use the database's default tablespace."}},"from":"17","status":"changed","to":"18"}],"content_hash":"fb03f6f667d384c4b950f14a1f43f40974b3d5b644c3f9e0538b1b04f1b700f8","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"Empty string"}],"editorial":{"advice":{"olap":"Use default_tablespace deliberately for bulk objects and spill-heavy jobs, checking I/O placement, compression support, and operational tooling before adoption.","oltp":"Keep default_tablespace aligned with schema-management policy and make important storage choices explicit in migrations. Benchmark any physical-layout change with production-shaped writes.","small":"Prefer the upstream default for default_tablespace unless the node has a verified alternate storage path or restore requirement; simplicity reduces recovery surprises."},"mechanism":["default_tablespace sets the default tablespace to create tables and indexes in. An empty string means use the database's default tablespace. It selects the destination for new persistent tables and indexes, not temporary objects or CREATE DATABASE; an invalid configured name falls back to the database default in some contexts.","default_tablespace is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.","It supplies a default only when SQL omits an explicit choice, so schema migrations, object-level options, privileges, and later ALTER operations can override or outlive it."],"pitfalls":["Changing default_tablespace in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.","Expecting a changed default to rewrite existing objects or override explicit DDL clauses.","Ignoring tablespace privileges, installed access methods or compression support, and restore portability.","Changing default_tablespace globally without a rollback plan and a client or operational compatibility test."],"references":[{"title":"PostgreSQL 19 Beta 4: default_tablespace","url":"https://www.postgresql.org/docs/19/runtime-config-client.html#GUC-DEFAULT-TABLESPACE"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["default_table_access_method","temp_tablespaces","default_toast_compression","check_function_bodies","maintenance_work_mem"],"summary":"default_tablespace is the PostgreSQL setting that defines the default tablespace to create tables and indexes in."},"enumvals":[],"first_version":"8.0","group":"Client Connection Defaults","group_slug":"client","imported_at":"2026-09-27T17:57:31.09648+08:00","intro_commit":{},"key":"default_tablespace","last_version":"20","max_val":"","min_val":"","name":"default_tablespace","position":100,"present_in":["8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"This variable specifies the default tablespace in which to create objects (tables and indexes) when a CREATE command does not explicitly specify a tablespace.","short_desc_zh":"","source_rev":"english-manuals:fcc6f4f7f0fc6911c24c9e02301819baaef04a878f7f7441259bb8146bed4669","unit":"","vartype":"string"}},"Definition":{"Collection":"guc","Key":"default_tablespace","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"default_tablespace","SourceRevision":"english-manuals:fcc6f4f7f0fc6911c24c9e02301819baaef04a878f7f7441259bb8146bed4669","Facts":{"boot_val":"","category":"Client Connection Defaults / Statement Behavior","context":"user","description":"This variable specifies the default tablespace in which to create objects (tables and indexes) when a CREATE command does not explicitly specify a tablespace. The value is either the name of a tablespace, or an empty string to specify using the default tablespace of the current database. If the value does not match the name of any existing tablespace, PostgreSQL will automatically use the default tablespace of the current database. If a nondefault tablespace is specified, the user must have CREATE privilege for it, or creation attempts will fail. This variable is not used for temporary tables; for them, temp_tablespaces is consulted instead. This variable is also not used when creating databases. By default, a new database inherits its tablespace setting from the template database it is copied from. If this parameter is set to a value other than the empty string when a partitioned table is created, the partitioned table's tablespace will be set to that value, which will be used as the default tablespace for partitions created in the future, even if default_tablespace has changed since then. For more information on tablespaces, see Section 22.6.","doc":{"anchor":"GUC-DEFAULT-TABLESPACE","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"An empty string means use the database's default tablespace.","lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"default_tablespace","short_desc":"Sets the default tablespace to create tables and indexes in.","source":"pg-settings-source-snapshot","unit":null,"vartype":"string"},"ManualEvidence":{"doc":{"anchor":"GUC-DEFAULT-TABLESPACE","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"default_tablespace","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"default_tablespace","Summary":"","BodyHTML":"\u003cp\u003e这个变量指定当一个\u003ccode\u003eCREATE\u003c/code\u003e命令没有显式指定一个表空间时，创建对象（表和索引）的默认表空间。\u003c/p\u003e\u003cp\u003e该值要么是一个表空间的名字，要么是一个指定使用当前数据库默认表空间的空字符串。如果该值和任何现有表空间的名字都不匹配，\u003cspan\u003ePostgreSQL\u003c/span\u003e将自动使用当前数据库的默认表空间。如果指定了一个非默认的表空间，用户必须对它有\u003ccode\u003eCREATE\u003c/code\u003e权限，否则创建尝试将失败。\u003c/p\u003e\u003cp\u003e这个变量不被用于临时表，对临时表会使用\u003ca href=\"/docs/18/runtime-config-client.html#GUC-TEMP-TABLESPACES\" rel=\"nofollow\"\u003etemp_tablespaces\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e创建数据库时也不会使用这个变量。默认情况下，一个新数据库会从它的模板数据库继承其表空间设置。\u003c/p\u003e\u003cp\u003e当一个分区表建立时如果这个参数被设置为空字符串以外的值，分区表的表空间将被设置为该值，将被用作未来建立分区的默认表空间，即使\u003ccode\u003edefault_tablespace\u003c/code\u003e已经改变。\u003c/p\u003e\u003cp\u003e有关表空间的更多的信息，请见\u003ca href=\"/docs/18/manage-ag-tablespaces.html\" rel=\"nofollow\"\u003e第 22.6 节\u003c/a\u003e。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"d121e69641228242952d6ea82be0923d17485f9f4fdeac6163f81d1a49c4a0d8","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e这个变量指定当一个\u003ccode class=\"command\"\u003eCREATE\u003c/code\u003e命令没有显式指定一个表空间时，创建对象（表和索引）的默认表空间。\u003c/p\u003e\u003cp\u003e该值要么是一个表空间的名字，要么是一个指定使用当前数据库默认表空间的空字符串。如果该值和任何现有表空间的名字都不匹配，\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e将自动使用当前数据库的默认表空间。如果指定了一个非默认的表空间，用户必须对它有\u003ccode class=\"literal\"\u003eCREATE\u003c/code\u003e权限，否则创建尝试将失败。\u003c/p\u003e\u003cp\u003e这个变量不被用于临时表，对临时表会使用\u003ca href=\"/docs/18/runtime-config-client.html#GUC-TEMP-TABLESPACES\"\u003etemp_tablespaces\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e创建数据库时也不会使用这个变量。默认情况下，一个新数据库会从它的模板数据库继承其表空间设置。\u003c/p\u003e\u003cp\u003e当一个分区表建立时如果这个参数被设置为空字符串以外的值，分区表的表空间将被设置为该值，将被用作未来建立分区的默认表空间，即使\u003ccode class=\"varname\"\u003edefault_tablespace\u003c/code\u003e已经改变。\u003c/p\u003e\u003cp\u003e有关表空间的更多的信息，请见\u003ca href=\"/docs/18/manage-ag-tablespaces.html\" title=\"22.6. 表空间\"\u003e第 22.6 节\u003c/a\u003e。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
