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

# EXECUTE

### EXECUTE

EXECUTE — 執行預備陳述式

### 語法

```

EXECUTE name [ ( parameter [, ...] ) ]
```

### 說明

`EXECUTE` 用來執行先前預備好的陳述式。由於預備陳述式只在工作階段期間存在，因此該預備陳述式必須是由目前工作階段中稍早執行的 `PREPARE` 陳述式所建立。

若建立該陳述式的 `PREPARE` 陳述式指定了一些參數，則必須將一組相容的參數傳給 `EXECUTE` 陳述式，否則會引發錯誤。請注意，預備陳述式（不同於函式）不會依據其參數的型別或數量進行多載；預備陳述式的名稱在資料庫工作階段中必須是唯一的。

有關預備陳述式建立與使用的更多資訊，請參閱 [PREPARE](https://docs.postgresql.tw/19/reference/sql-commands/sql-prepare.md)。

### 參數

*`name`* : 要執行的預備陳述式名稱。

*`parameter`* : 傳給預備陳述式之參數的實際值。這必須是一個運算式，其產生的值與此參數的資料型別相容，而該資料型別是在建立預備陳述式時所決定的。

### 輸出

`EXECUTE` 傳回的命令標籤是該預備陳述式的命令標籤，而不是 `EXECUTE`。

### 範例

範例收錄於 [PREPARE](https://docs.postgresql.tw/19/reference/sql-commands/sql-prepare.md) 文件的[範例](https://docs.postgresql.tw/19/reference/sql-commands/sql-prepare.md#fan-li)一節中。

### 相容性

SQL 標準包含 `EXECUTE` 陳述式，但它僅供嵌入式 SQL 使用。此版本的 `EXECUTE` 陳述式所使用的語法也略有不同。

### 另請參閱

[DEALLOCATE](https://docs.postgresql.tw/19/reference/sql-commands/sql-deallocate.md), [PREPARE](https://docs.postgresql.tw/19/reference/sql-commands/sql-prepare.md)

***

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


---

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