doc-exports/docs/dws/dev/dws_04_0582.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

135 lines
13 KiB
HTML

<a name="EN-US_TOPIC_0000001188482182"></a><a name="EN-US_TOPIC_0000001188482182"></a>
<h1 class="topictitle1">PG_DATABASE</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001188482182__a1394ee1be7024608b9fb97d1b872b3a1"><strong id="EN-US_TOPIC_0000001188482182__b31011246132912">PG_DATABASE</strong> records information about the available databases.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188482182__t8d1911a1aaa6444fb4622cb1415969de" frame="border" border="1" rules="all"><caption><b>Table 1 </b>PG_DATABASE columns</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188482182__ra8ce5dd940d14530accc3a6dc12be239"><th align="left" class="cellrowborder" valign="top" width="25.77%" id="mcps1.3.2.2.4.1.1"><p id="EN-US_TOPIC_0000001188482182__acdbb2b663049403bb1c657f4c01fe271"><strong id="EN-US_TOPIC_0000001188482182__b84235270691445">Name</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16.73%" id="mcps1.3.2.2.4.1.2"><p id="EN-US_TOPIC_0000001188482182__aae526ee2e28d4d0ab39be70af418623b">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="57.49999999999999%" id="mcps1.3.2.2.4.1.3"><p id="EN-US_TOPIC_0000001188482182__aee93a2d017fb483993a033afc5f5cceb">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188482182__rdf8206fbcc974d928c28b82212c6272c"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__ad8ae4f391bb946f59945d97310056864">datname</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__ac241898c7de74f129583f6e1852f7860">name</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__a28f2e8bc4f44475e9a6929c5639e772f">Database name</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__rc93917d6bfc5491798facf38eb5d863c"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__ab7d9f3b46efb401987f054cbe06cbf78">datdba</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__a64525633faf24daf9120b9a46334b18b">oid</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__a98488178fda54604a1457345c128ccf5">Owner of the database, usually the user who created it</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r19c8680778e349b8babc0d75bcbbbe00"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__a0e5b6b088a8f4a67941fd07b625956a4">encoding</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__a4e0a4e0ff0074197a77ffb34796119fd">integer</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__a8a39792401f34a9cb6d129a5391b4e39">Character encoding for this database</p>
<p id="EN-US_TOPIC_0000001188482182__p6486102632411">You can use pg_encoding_to_char() to convert this number to the encoding name.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r73aff32a7b194d1e8e555eefafe6cc7c"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__aafc549e6e7954ccd8c1f6dd256676be9">datcollate</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__ab11eaf196554463a9cedb813d8d1ea77">name</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__af74dbcd325fe47968781cfeb2d7a4831">Sequence used by the database</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r2fc20bc93a4846b29c6a51de3c1850ad"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__a09f3e5a5a5c14a2498b24b9f33073589">datctype</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__ac12ef146de95419d989411b607cc50cd">name</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__afc907fcc61c64818a7e7c5cbcf0f680d">Character type used by the database</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__re617b0446f2a4154936052e233296fe4"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__afba6bc1f4e0641c1a48aca7e9ce87af4">datistemplate</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__a5d62a3904f6343988c9f9178f201a664"><span id="EN-US_TOPIC_0000001188482182__text1113917125324">boolean</span></p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__a71be37fe94f54db5a560aa041733b7b0">Whether this column can serve as a template database</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r7898ff19111743118979a16f220c9734"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__a5ae41fdffef04f99b16be5c55f5a7454">datallowconn</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__ac0eee947265443f591dee6195fcbafa2"><span id="EN-US_TOPIC_0000001188482182__text6144161383218">boolean</span></p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__acda96d66a3954a11bd986f92fd29e7a3">If false then no one can connect to this database. This column is used to protect the <strong id="EN-US_TOPIC_0000001188482182__b136998582941948">template0</strong> database from being altered.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__ra9ee09ab6e53477c8ffaed1d39931d2c"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__a8cd52b99c73c4767ab6be6b92a997570">datconnlimit</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__abe7ea9857a194a9d84508334f6a622ac">integer</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__a6fe0592ebc1b4ece82330f6aaa5ff5ff">Maximum number of concurrent connections allowed on this database. <strong id="EN-US_TOPIC_0000001188482182__b842352706193719">-1</strong> indicates no limit.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r9073bef068704b65a384fef7eab883e8"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__a56223515761e459195f4d91044263849">datlastsysoid</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__a06975ff86efe47cca255a9e0d6a6c831">oid</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__a7cd7bcc2ebd54911bf5c1c300c5239ce">Last system OID in the database</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r095a8d5607684cff9371a0e940893c34"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__ac424947a5ee042dfa7330d6441428aef">datfrozenxid</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__ab47433fee7c44709b760f0ae83c7b8f7">xid32</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__p3787183963214">Tracks whether the database needs to be vacuumed in order to prevent transaction ID wraparound.</p>
<p id="EN-US_TOPIC_0000001188482182__abbfb25de76a44f9b95e280ee6e855161">To ensure forward compatibility, this column is reserved. The <strong id="EN-US_TOPIC_0000001188482182__b0384124074217">datfrozenxid64</strong> column is added to record the information.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r1cfc7748808c49f692f9c269d01970a2"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__a1c70f8f1c6714cabb8702a510f53d744">dattablespace</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__a91281a31c88e4cc893fe7ea13ed26866">oid</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__a4875a637ae944e98a2e06229be499abb">Default tablespace of the database</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r31231f0b537741fb8bdfecfbd64a1b6f"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__a573e828acd02425ea5b282b77b33f03d">datcompatibility</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__ad189dbda00b64533853d82e78e360ed1">name</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__af81f368daf0e4391a7ab1c74e97448d0">Database compatibility mode</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__r8f794ef4c0484a3c90adc3f5056fc1f9"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__af93c74cadc464fc082791bc8cd753310">datacl</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__a9665bf6bf60b4b0bb27e1a22fd86a79b">aclitem[]</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__a04d6798f233f4a138de2b33c62554ccd">Access permissions</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482182__row027011018487"><td class="cellrowborder" valign="top" width="25.77%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482182__p127014019483">datfrozenxid64</p>
</td>
<td class="cellrowborder" valign="top" width="16.73%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482182__p172710074815">xid</p>
</td>
<td class="cellrowborder" valign="top" width="57.49999999999999%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482182__p20271100482">Tracks whether the database needs to be vacuumed in order to prevent transaction ID wraparound.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482182__section6568205984114"><h4 class="sectiontitle">Example</h4><p id="EN-US_TOPIC_0000001188482182__p8382535102412">Run the following command to view the owner, compatibility mode, and access permissions of a database:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188482182__screen9680181404415"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">datname</span><span class="p">,</span><span class="w"> </span><span class="n">datdba</span><span class="p">,</span><span class="n">datcompatibility</span><span class="p">,</span><span class="n">datacl</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">pg_database</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">datname</span><span class="o">=</span><span class="s1">'database_name'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482182__p5431912462">View the encoding of a database:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188482182__screen31431015713"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">pg_encoding_to_char</span><span class="p">(</span><span class="k">encoding</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_database</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">datname</span><span class="o">=</span><span class="s1">'database_name'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0561.html">System Catalogs</a></div>
</div>
</div>