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

# ABORT

### ABORT

ABORT — 中止目前的交易

### 語法

```

ABORT [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
```

### 說明

`ABORT` 會回復目前的交易，並使該交易所做的所有更新都被捨棄。此命令的行為與標準 SQL 命令 [`ROLLBACK`](https://docs.postgresql.tw/19/reference/sql-commands/sql-rollback.md) 完全相同，僅因歷史因素而存在。

### 參數

`WORK`\
`TRANSACTION` : 可省略的關鍵字，沒有任何效果。

`AND CHAIN` : 若指定 `AND CHAIN`，會立即以與剛結束的交易相同的交易特性（請參閱 [`SET TRANSACTION`](https://docs.postgresql.tw/19/reference/sql-commands/sql-set-transaction.md)）開始一個新的交易。否則，不會開始新的交易。

### 注意事項

請使用 [`COMMIT`](https://docs.postgresql.tw/19/reference/sql-commands/sql-commit.md) 來成功結束交易。

在交易區塊之外發出 `ABORT` 會產生警告，除此之外沒有任何作用。

### 範例

若要中止所有變更：

```

ABORT;
```

### 相容性

此命令是因歷史因素而存在的 PostgreSQL 擴充語法。`ROLLBACK` 是等效的標準 SQL 命令。

### 另請參閱

[BEGIN](https://docs.postgresql.tw/19/reference/sql-commands/sql-begin.md), [COMMIT](https://docs.postgresql.tw/19/reference/sql-commands/sql-commit.md), [ROLLBACK](https://docs.postgresql.tw/19/reference/sql-commands/sql-rollback.md)

***

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


---

# 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-abort.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.
