> 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-createtable/sql-createtable-on-commit-options.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# CREATE TABLE：ON COMMIT 選項

[返回 CREATE TABLE 主頁](https://docs.postgresql.tw/19/reference/sql-commands/sql-createtable.md)。

## `PRESERVE ROWS` [#](#sql-createtable-parms-on-commit-preserve-rows) <a href="#sql-createtable-parms-on-commit-preserve-rows" id="sql-createtable-parms-on-commit-preserve-rows"></a>

在交易結束時不採取任何特殊動作。這是預設行為。

## `DELETE ROWS` [#](#sql-createtable-parms-on-commit-delete-rows) <a href="#sql-createtable-parms-on-commit-delete-rows" id="sql-createtable-parms-on-commit-delete-rows"></a>

暫存資料表中的所有資料列會在每個交易區塊結束時被刪除。基本上，每次提交時都會自動執行一次 [`TRUNCATE`](https://docs.postgresql.tw/19/reference/sql-commands/sql-truncate.md)。用在分割資料表上時，此動作不會串聯到其分割區。

## `DROP` [#](#sql-createtable-parms-on-commit-drop) <a href="#sql-createtable-parms-on-commit-drop" id="sql-createtable-parms-on-commit-drop"></a>

暫存資料表會在目前交易區塊結束時被移除。用在分割資料表上時，此動作會移除其分割區；用在具有繼承子資料表的資料表上時，則會移除相依的子資料表。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/sql-createtable.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-createtable/sql-createtable-on-commit-options.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.
