> 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/internals/catalogs/catalog-pg-database.md).

# 52.15. pg\_database \#

The catalog `pg_database` stores information about the available databases. Databases are created with the [`CREATE DATABASE`](/reference/sql-commands/sql-createdatabase.md) command. Consult [Chapter 22](/server-administration/managing-databases.md) for details about the meaning of some of the parameters.

Unlike most system catalogs, `pg_database` is shared across all databases of a cluster: there is only one copy of `pg_database` per cluster, not one per database.

**Table 52.15. `pg_database` Columns**

| <p>Column Type</p><p>Description</p>                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>oid</code> <code>oid</code></p><p>Row identifier</p>                                                                                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>datname</code> <code>name</code></p><p>Database name</p>                                                                                                                                                                                                                                                                                                                                                                                                               |
| <p><code>datdba</code> <code>oid</code> (references <a href="/pages/nyEMOe5gQKgypFQTDbjS"><code>pg\_authid</code></a>.<code>oid</code>)</p><p>Owner of the database, usually the user who created it</p>                                                                                                                                                                                                                                                                        |
| <p><code>encoding</code> <code>int4</code></p><p>Character encoding for this database (<a href="/pages/c8lw51k5xRREjrdY9Xxk#PG-ENCODING-TO-CHAR"><code>pg\_encoding\_to\_char()</code></a> can translate this number to the encoding name)</p>                                                                                                                                                                                                                                  |
| <p><code>datlocprovider</code> <code>char</code></p><p>Locale provider for this database: <code>b</code> = builtin, <code>c</code> = libc, <code>i</code> = icu</p>                                                                                                                                                                                                                                                                                                             |
| <p><code>datistemplate</code> <code>bool</code></p><p>If true, then this database can be cloned by any user with <code>CREATEDB</code> privileges; if false, then only superusers or the owner of the database can clone it.</p>                                                                                                                                                                                                                                                |
| <p><code>datallowconn</code> <code>bool</code></p><p>If false then no one can connect to this database. This is used to protect the <code>template0</code> database from being altered.</p>                                                                                                                                                                                                                                                                                     |
| <p><code>dathasloginevt</code> <code>bool</code></p><p>Indicates that there are login event triggers defined for this database. This flag is used to avoid extra lookups on the <code>pg\_event\_trigger</code> table during each backend startup. This flag is used internally by PostgreSQL and should not be manually altered or read for monitoring purposes.</p>                                                                                                           |
| <p><code>datconnlimit</code> <code>int4</code></p><p>Sets maximum number of concurrent connections that can be made to this database. -1 means no limit, -2 indicates the database is invalid.</p>                                                                                                                                                                                                                                                                              |
| <p><code>datfrozenxid</code> <code>xid</code></p><p>All transaction IDs before this one have been replaced with a permanent (“frozen”) transaction ID in this database. This is used to track whether the database needs to be vacuumed in order to prevent transaction ID wraparound or to allow <code>pg\_xact</code> to be shrunk. It is the minimum of the per-table <a href="/pages/b1fii6hWVNacZFXaxWON"><code>pg\_class</code></a>.<code>relfrozenxid</code> values.</p> |
| <p><code>datminmxid</code> <code>xid</code></p><p>All multixact IDs before this one have been replaced with a transaction ID in this database. This is used to track whether the database needs to be vacuumed in order to prevent multixact ID wraparound or to allow <code>pg\_multixact</code> to be shrunk. It is the minimum of the per-table <a href="/pages/b1fii6hWVNacZFXaxWON"><code>pg\_class</code></a>.<code>relminmxid</code> values.</p>                         |
| <p><code>dattablespace</code> <code>oid</code> (references <a href="/pages/6WQ83gEshTUMqFNO2jhL"><code>pg\_tablespace</code></a>.<code>oid</code>)</p><p>The default tablespace for the database. Within this database, all tables for which <a href="/pages/b1fii6hWVNacZFXaxWON"><code>pg\_class</code></a>.<code>reltablespace</code> is zero will be stored in this tablespace; in particular, all the non-shared system catalogs will be there.</p>                        |
| <p><code>datcollate</code> <code>text</code></p><p>LC\_COLLATE for this database</p>                                                                                                                                                                                                                                                                                                                                                                                            |
| <p><code>datctype</code> <code>text</code></p><p>LC\_CTYPE for this database</p>                                                                                                                                                                                                                                                                                                                                                                                                |
| <p><code>datlocale</code> <code>text</code></p><p>Collation provider locale name for this database. If the provider is <code>libc</code>, <code>datlocale</code> is <code>NULL</code>; <code>datcollate</code> and <code>datctype</code> are used instead.</p>                                                                                                                                                                                                                  |
| <p><code>daticurules</code> <code>text</code></p><p>ICU collation rules for this database</p>                                                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>datcollversion</code> <code>text</code></p><p>Provider-specific version of the collation. This is recorded when the database is created and then checked when it is used, to detect changes in the collation definition that could lead to data corruption.</p>                                                                                                                                                                                                        |
| <p><code>datacl</code> <code>aclitem\[]</code></p><p>Access privileges; see <a href="/pages/VX212noXJkZ6WiwCHQE7">Section 5.8</a> for details</p>                                                                                                                                                                                                                                                                                                                               |

<br>

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/catalog-pg-database.html)（英文原文，待翻譯）


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.postgresql.tw/internals/catalogs/catalog-pg-database.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
