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

# 52.15. pg\_database \#

### 52.15. `pg_database` [#](#catalog-pg-database) <a href="#catalog-pg-database" id="catalog-pg-database"></a>

系統目錄 `pg_database` 存放可用資料庫的相關資訊。資料庫是以 [`CREATE DATABASE`](https://docs.postgresql.tw/19/reference/sql-commands/sql-createdatabase.md) 命令建立的。關於部分參數意義的詳細資訊，請參閱[第 22 章](https://docs.postgresql.tw/19/server-administration/managing-databases.md)。

與大多數系統目錄不同，`pg_database` 由叢集中的所有資料庫共享：每個叢集只有一份 `pg_database`，而不是每個資料庫各一份。

#### 表 52.15. `pg_database` 欄位 [#](#catalog-pg-database-columns) <a href="#catalog-pg-database-columns" id="catalog-pg-database-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><code>oid</code> <code>oid</code></p><p>資料列識別碼</p>                                                                                                                                                                                                                                                                                                                                                  |
| <p><code>datname</code> <code>name</code></p><p>資料庫名稱</p>                                                                                                                                                                                                                                                                                                                                              |
| <p><code>datdba</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-authid.md"><code>pg\_authid</code></a>.<code>oid</code>）</p><p>資料庫的擁有者，通常是建立它的使用者</p>                                                                                                                                                                                                 |
| <p><code>encoding</code> <code>int4</code></p><p>此資料庫的字元編碼（<a href="https://docs.postgresql.tw/19/the-sql-language/functions/functions-info/functions-info-catalog.md#functions-info-catalog-table"><code>pg\_encoding\_to\_char()</code></a> 可以將此數字轉換為編碼名稱）</p>                                                                                                                                       |
| <p><code>datlocprovider</code> <code>char</code></p><p>此資料庫的區域設定提供者：<code>b</code> = builtin， <code>c</code> = libc，<code>i</code> = icu</p>                                                                                                                                                                                                                                                           |
| <p><code>datistemplate</code> <code>bool</code></p><p>若為真，則任何具有 <code>CREATEDB</code> 權限的使用者都可以複製此資料庫；若為假，則只有超級使用者或資料庫的擁有者可以複製它。</p>                                                                                                                                                                                                                                                                   |
| <p><code>datallowconn</code> <code>bool</code></p><p>若為假，則沒有人能連線到此資料庫。這用來保護 <code>template0</code> 資料庫不被修改。</p>                                                                                                                                                                                                                                                                                        |
| <p><code>dathasloginevt</code> <code>bool</code></p><p>表示此資料庫中定義了登入事件觸發程序。此旗標用來避免在每次後端啟動時，對 <code>pg\_event\_trigger</code> 資料表進行額外的查詢。此旗標由 PostgreSQL 內部使用，不應手動修改，也不應為了監控目的而讀取。</p>                                                                                                                                                                                                                   |
| <p><code>datconnlimit</code> <code>int4</code></p><p>設定可對此資料庫建立的最大同時連線數。-1 表示沒有限制，-2 表示該資料庫無效。</p>                                                                                                                                                                                                                                                                                                     |
| <p><code>datfrozenxid</code> <code>xid</code></p><p>在此資料庫中，此 ID 之前的所有交易 ID 都已被替換為永久的（“frozen”，凍結）交易 ID。這用來追蹤資料庫是否需要執行 vacuum，以防止交易 ID 回捲，或讓 <code>pg\_xact</code> 得以縮減。它是各資料表 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>relfrozenxid</code> 值中的最小值。</p>                                                                          |
| <p><code>datminmxid</code> <code>xid</code></p><p>在此資料庫中，此 ID 之前的所有 multixact ID 都已被替換為交易 ID。這用來追蹤資料庫是否需要執行 vacuum，以防止 multixact ID 回捲，或讓 <code>pg\_multixact</code> 得以縮減。它是各資料表 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>relminmxid</code> 值中的最小值。</p>                                                                         |
| <p><code>dattablespace</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-tablespace.md"><code>pg\_tablespace</code></a>.<code>oid</code>）</p><p>此資料庫的預設資料表空間。在此資料庫中，所有 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>reltablespace</code> 為零的資料表都會存放在此資料表空間中；特別是，所有非共享的系統目錄都會在這裡。</p> |
| <p><code>datcollate</code> <code>text</code></p><p>此資料庫的 LC\_COLLATE</p>                                                                                                                                                                                                                                                                                                                               |
| <p><code>datctype</code> <code>text</code></p><p>此資料庫的 LC\_CTYPE</p>                                                                                                                                                                                                                                                                                                                                   |
| <p><code>datlocale</code> <code>text</code></p><p>此資料庫的定序提供者區域設定名稱。若提供者為 <code>libc</code>，則 <code>datlocale</code> 為 <code>NULL</code>，改為使用 <code>datcollate</code> 與 <code>datctype</code>。</p>                                                                                                                                                                                                      |
| <p><code>daticurules</code> <code>text</code></p><p>此資料庫的 ICU 定序規則</p>                                                                                                                                                                                                                                                                                                                                 |
| <p><code>datcollversion</code> <code>text</code></p><p>定序的提供者特定版本。這會在建立資料庫時記錄下來，並在使用資料庫時檢查，以偵測可能導致資料損毀的定序定義變更。</p>                                                                                                                                                                                                                                                                                     |
| <p><code>datacl</code> <code>aclitem\[]</code></p><p>存取權限；詳細資訊請參閱<a href="https://docs.postgresql.tw/19/the-sql-language/ddl/ddl-priv.md">第 5.8 節</a></p>                                                                                                                                                                                                                                              |

<br>

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/catalog-pg-database.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-database.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.
