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

# 53.16. pg\_prepared\_statements \#

### 53.16. `pg_prepared_statements` [#](#view-pg-prepared-statements) <a href="#view-pg-prepared-statements" id="view-pg-prepared-statements"></a>

檢視表 `pg_prepared_statements` 顯示目前工作階段中可用的所有預備陳述式。關於預備陳述式的更多資訊，請參閱 [PREPARE](https://docs.postgresql.tw/19/reference/sql-commands/sql-prepare.md)。

`pg_prepared_statements` 中每個預備陳述式各有一筆資料列。建立新的預備陳述式時，會在此檢視表中加入資料列；釋放預備陳述式時（例如透過 [`DEALLOCATE`](https://docs.postgresql.tw/19/reference/sql-commands/sql-deallocate.md) 命令），則會移除資料列。

#### 表 53.16. `pg_prepared_statements` 欄位 [#](#view-pg-prepared-statements-columns) <a href="#view-pg-prepared-statements-columns" id="view-pg-prepared-statements-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                 |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>name</code> <code>text</code></p><p>預備陳述式的識別名稱</p>                                                                                                                                                          |
| <p><code>statement</code> <code>text</code></p><p>用戶端為建立此預備陳述式所送出的查詢字串。對於透過 SQL 建立的預備陳述式，這是用戶端送出的 <code>PREPARE</code> 陳述式。對於透過前端／後端協定建立的預備陳述式，這是預備陳述式本身的文字。</p>                                                     |
| <p><code>prepare\_time</code> <code>timestamptz</code></p><p>建立此預備陳述式的時間</p>                                                                                                                                         |
| <p><code>parameter\_types</code> <code>regtype\[]</code></p><p>此預備陳述式預期的參數型別，以 <code>regtype</code> 陣列的形式呈現。將 <code>regtype</code> 值轉型為 <code>oid</code>，即可取得此陣列中某個元素所對應的 OID。</p>                                   |
| <p><code>result\_types</code> <code>regtype\[]</code></p><p>此預備陳述式所傳回之欄位的型別，以 <code>regtype</code> 陣列的形式呈現。將 <code>regtype</code> 值轉型為 <code>oid</code>，即可取得此陣列中某個元素所對應的 OID。若預備陳述式不提供結果（例如 DML 陳述式），則此欄位為 null。</p> |
| <p><code>from\_sql</code> <code>bool</code></p><p><code>true</code> 表示此預備陳述式是透過 <code>PREPARE</code> SQL 命令建立的；<code>false</code> 表示此陳述式是透過前端／後端協定預備的</p>                                                            |
| <p><code>generic\_plans</code> <code>int8</code></p><p>選用通用計畫的次數</p>                                                                                                                                                 |
| <p><code>custom\_plans</code> <code>int8</code></p><p>選用客製計畫的次數</p>                                                                                                                                                  |

<br>

檢視表 `pg_prepared_statements` 是唯讀的。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/view-pg-prepared-statements.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/internals/views/view-pg-prepared-statements.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.
