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

# 52.20. pg\_enum \#

### 52.20. `pg_enum` [#](#catalog-pg-enum) <a href="#catalog-pg-enum" id="catalog-pg-enum"></a>

`pg_enum` 系統目錄包含顯示每個列舉型別之值與標籤的項目。某個列舉值的內部表示法，實際上就是它在 `pg_enum` 中所對應資料列的 OID。

#### 表 52.20. `pg_enum` 欄位 [#](#catalog-pg-enum-columns) <a href="#catalog-pg-enum-columns" id="catalog-pg-enum-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                                                                                                       |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>oid</code> <code>oid</code></p><p>資料列識別碼</p>                                                                                                                                                                                                                                                      |
| <p><code>enumtypid</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a>.<code>oid</code>）</p><p>擁有此列舉值之 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a> 項目的 OID</p> |
| <p><code>enumsortorder</code> <code>float4</code></p><p>此列舉值在其列舉型別中的排序位置</p>                                                                                                                                                                                                                               |
| <p><code>enumlabel</code> <code>name</code></p><p>此列舉值的文字標籤</p>                                                                                                                                                                                                                                            |

<br>

`pg_enum` 資料列的 OID 遵循一項特殊規則：偶數 OID 保證會依照其列舉型別的排序順序排列。也就是說，若兩個偶數 OID 屬於同一個列舉型別，則較小的 OID 必定具有較小的 `enumsortorder` 值。奇數 OID 值則不需要與排序順序有任何關聯。此規則讓列舉比較常式在許多常見情況下可以避免查詢系統目錄。建立與修改列舉型別的常式會盡可能嘗試為列舉值指派偶數 OID。

建立列舉型別時，其成員會被指派排序位置 1..*`n`*。但之後加入的成員可能會被給予負的或帶小數的 `enumsortorder` 值。對這些值唯一的要求，是它們在每個列舉型別內必須正確排序且不重複。

***

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


---

# 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/catalogs/catalog-pg-enum.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.
