> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/reference/sql-commands/sql-altertablespace.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# ALTER TABLESPACE

### ALTER TABLESPACE

ALTER TABLESPACE — 變更資料表空間的定義

### 語法

```

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 [, ... ] )
```

### 說明

`ALTER TABLESPACE` 可用來變更資料表空間的定義。

你必須擁有該資料表空間，才能變更其定義。若要變更擁有者，你還必須能夠 `SET ROLE` 成為新的擁有者角色。（請注意，超級使用者自動具有這些權限。）

### 參數

*`name`* : 現有資料表空間的名稱。

*`new_name`* : 資料表空間的新名稱。新名稱不能以 `pg_` 開頭，因為這類名稱保留給系統資料表空間使用。

*`new_owner`* : 資料表空間的新擁有者。

*`tablespace_option`* : 要設定或重設的資料表空間參數。目前可用的參數只有 `seq_page_cost`、`random_page_cost`、`effective_io_concurrency` 與 `maintenance_io_concurrency`。為特定資料表空間設定這些值，會覆寫規劃器對於讀取該資料表空間中資料表之頁面成本的一般估計，以及發出多少個並行 I/O 的一般估計；這些一般估計是由同名的設定參數所決定（請參閱 [seq\_page\_cost](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-query.md#GUC-SEQ-PAGE-COST)、[random\_page\_cost](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-query.md#GUC-RANDOM-PAGE-COST)、[effective\_io\_concurrency](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-resource.md#GUC-EFFECTIVE-IO-CONCURRENCY)、[maintenance\_io\_concurrency](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-resource.md#GUC-MAINTENANCE-IO-CONCURRENCY)）。若某個資料表空間位於比 I/O 子系統其餘部分更快或更慢的磁碟上，這可能很有用。

### 範例

將資料表空間 `index_space` 重新命名為 `fast_raid`：

```

ALTER TABLESPACE index_space RENAME TO fast_raid;
```

變更資料表空間 `index_space` 的擁有者：

```

ALTER TABLESPACE index_space OWNER TO mary;
```

### 相容性

SQL 標準中沒有 `ALTER TABLESPACE` 陳述式。

### 另請參閱

[CREATE TABLESPACE](https://docs.postgresql.tw/19/reference/sql-commands/sql-createtablespace.md), [DROP TABLESPACE](https://docs.postgresql.tw/19/reference/sql-commands/sql-droptablespace.md)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/sql-altertablespace.html)（原文版本：18.6；核對日期：2026-10-04）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/reference/sql-commands/sql-altertablespace.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
