📄 catalogs.sgml
字号:
<!-- Documentation of the system catalogs, directed toward PostgreSQL developers $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.115 2005/11/04 23:13:59 petere Exp $ --><chapter id="catalogs"> <title>System Catalogs</title> <para> The system catalogs are the place where a relational database management system stores schema metadata, such as information about tables and columns, and internal bookkeeping information. <productname>PostgreSQL</productname>'s system catalogs are regular tables. You can drop and recreate the tables, add columns, insert and update values, and severely mess up your system that way. Normally, one should not change the system catalogs by hand, there are always SQL commands to do that. (For example, <command>CREATE DATABASE</command> inserts a row into the <structname>pg_database</structname> catalog — and actually creates the database on disk.) There are some exceptions for particularly esoteric operations, such as adding index access methods. </para> <sect1 id="catalogs-overview"> <title>Overview</title> <para> <xref linkend="catalog-table"> lists the system catalogs. More detailed documentation of each catalog follows below. </para> <para> Most system catalogs are copied from the template database during database creation and are thereafter database-specific. A few catalogs are physically shared across all databases in a cluster; these are noted in the descriptions of the individual catalogs. </para> <table id="catalog-table"> <title>System Catalogs</title> <tgroup cols="2"> <thead> <row> <entry>Catalog Name</entry> <entry>Purpose</entry> </row> </thead> <tbody> <row> <entry><link linkend="catalog-pg-aggregate"><structname>pg_aggregate</structname></link></entry> <entry>aggregate functions</entry> </row> <row> <entry><link linkend="catalog-pg-am"><structname>pg_am</structname></link></entry> <entry>index access methods</entry> </row> <row> <entry><link linkend="catalog-pg-amop"><structname>pg_amop</structname></link></entry> <entry>access method operators</entry> </row> <row> <entry><link linkend="catalog-pg-amproc"><structname>pg_amproc</structname></link></entry> <entry>access method support procedures</entry> </row> <row> <entry><link linkend="catalog-pg-attrdef"><structname>pg_attrdef</structname></link></entry> <entry>column default values</entry> </row> <row> <entry><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link></entry> <entry>table columns (<quote>attributes</quote>)</entry> </row> <row> <entry><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link></entry> <entry>authorization identifiers (roles)</entry> </row> <row> <entry><link linkend="catalog-pg-auth-members"><structname>pg_auth_members</structname></link></entry> <entry>authorization identifier membership relationships</entry> </row> <row> <entry><link linkend="catalog-pg-autovacuum"><structname>pg_autovacuum</structname></link></entry> <entry>per-relation autovacuum configuration parameters</entry> </row> <row> <entry><link linkend="catalog-pg-cast"><structname>pg_cast</structname></link></entry> <entry>casts (data type conversions)</entry> </row> <row> <entry><link linkend="catalog-pg-class"><structname>pg_class</structname></link></entry> <entry>tables, indexes, sequences, views (<quote>relations</quote>)</entry> </row> <row> <entry><link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link></entry> <entry>check constraints, unique constraints, primary key constraints, foreign key constraints</entry> </row> <row> <entry><link linkend="catalog-pg-conversion"><structname>pg_conversion</structname></link></entry> <entry>encoding conversion information</entry> </row> <row> <entry><link linkend="catalog-pg-database"><structname>pg_database</structname></link></entry> <entry>databases within this database cluster</entry> </row> <row> <entry><link linkend="catalog-pg-depend"><structname>pg_depend</structname></link></entry> <entry>dependencies between database objects</entry> </row> <row> <entry><link linkend="catalog-pg-description"><structname>pg_description</structname></link></entry> <entry>descriptions or comments on database objects</entry> </row> <row> <entry><link linkend="catalog-pg-index"><structname>pg_index</structname></link></entry> <entry>additional index information</entry> </row> <row> <entry><link linkend="catalog-pg-inherits"><structname>pg_inherits</structname></link></entry> <entry>table inheritance hierarchy</entry> </row> <row> <entry><link linkend="catalog-pg-language"><structname>pg_language</structname></link></entry> <entry>languages for writing functions</entry> </row> <row> <entry><link linkend="catalog-pg-largeobject"><structname>pg_largeobject</structname></link></entry> <entry>large objects</entry> </row> <row> <entry><link linkend="catalog-pg-listener"><structname>pg_listener</structname></link></entry> <entry>asynchronous notification support</entry> </row> <row> <entry><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link></entry> <entry>schemas</entry> </row> <row> <entry><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link></entry> <entry>index access method operator classes</entry> </row> <row> <entry><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link></entry> <entry>operators</entry> </row> <row> <entry><link linkend="catalog-pg-pltemplate"><structname>pg_pltemplate</structname></link></entry> <entry>template data for procedural languages</entry> </row> <row> <entry><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link></entry> <entry>functions and procedures</entry> </row> <row> <entry><link linkend="catalog-pg-rewrite"><structname>pg_rewrite</structname></link></entry> <entry>query rewrite rules</entry> </row> <row> <entry><link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link></entry> <entry>dependencies on shared objects</entry> </row> <row> <entry><link linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link></entry> <entry>planner statistics</entry> </row> <row> <entry><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link></entry> <entry>tablespaces within this database cluster</entry> </row> <row> <entry><link linkend="catalog-pg-trigger"><structname>pg_trigger</structname></link></entry> <entry>triggers</entry> </row> <row> <entry><link linkend="catalog-pg-type"><structname>pg_type</structname></link></entry> <entry>data types</entry> </row> </tbody> </tgroup> </table> </sect1> <sect1 id="catalog-pg-aggregate"> <title><structname>pg_aggregate</structname></title> <indexterm zone="catalog-pg-aggregate"> <primary>pg_aggregate</primary> </indexterm> <para> The catalog <structname>pg_aggregate</structname> stores information about aggregate functions. An aggregate function is a function that operates on a set of values (typically one column from each row that matches a query condition) and returns a single value computed from all these values. Typical aggregate functions are <function>sum</function>, <function>count</function>, and <function>max</function>. Each entry in <structname>pg_aggregate</structname> is an extension of an entry in <structname>pg_proc</structname>. The <structname>pg_proc</structname> entry carries the aggregate's name, input and output data types, and other information that is similar to ordinary functions. </para> <table> <title><structname>pg_aggregate</> Columns</title> <tgroup cols=4> <thead> <row> <entry>Name</entry> <entry>Type</entry> <entry>References</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><structfield>aggfnoid</structfield></entry> <entry><type>regproc</type></entry> <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry> <entry><structname>pg_proc</structname> OID of the aggregate function</entry> </row> <row> <entry><structfield>aggtransfn</structfield></entry> <entry><type>regproc</type></entry> <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry> <entry>Transition function</entry> </row> <row> <entry><structfield>aggfinalfn</structfield></entry> <entry><type>regproc</type></entry> <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry> <entry>Final function (zero if none)</entry> </row> <row> <entry><structfield>aggsortop</structfield></entry> <entry><type>oid</type></entry> <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry> <entry>Associated sort operator (zero if none)</entry> </row> <row> <entry><structfield>aggtranstype</structfield></entry> <entry><type>oid</type></entry> <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry> <entry>Data type of the aggregate function's internal transition (state) data</entry> </row> <row> <entry><structfield>agginitval</structfield></entry> <entry><type>text</type></entry> <entry></entry> <entry> The initial value of the transition state. This is a text field containing the initial value in its external string representation. If this field is null, the transition state value starts out null. </entry> </row> </tbody> </tgroup> </table> <para> New aggregate functions are registered with the <command>CREATE AGGREGATE</command> command. See <xref linkend="xaggr"> for more information about writing aggregate functions and the meaning of the transition functions, etc. </para> </sect1> <sect1 id="catalog-pg-am"> <title><structname>pg_am</structname></title> <indexterm zone="catalog-pg-am"> <primary>pg_am</primary> </indexterm> <para> The catalog <structname>pg_am</structname> stores information about index access methods. There is one row for each index access method supported by the system. The contents of this catalog are discussed in detail in <xref linkend="indexam">. </para> <table> <title><structname>pg_am</> Columns</title> <tgroup cols=4> <thead> <row> <entry>Name</entry> <entry>Type</entry> <entry>References</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><structfield>amname</structfield></entry> <entry><type>name</type></entry> <entry></entry> <entry>Name of the access method</entry> </row> <row> <entry><structfield>amstrategies</structfield></entry> <entry><type>int2</type></entry> <entry></entry> <entry>Number of operator strategies for this access method</entry> </row> <row> <entry><structfield>amsupport</structfield></entry> <entry><type>int2</type></entry> <entry></entry> <entry>Number of support routines for this access method</entry> </row> <row> <entry><structfield>amorderstrategy</structfield></entry> <entry><type>int2</type></entry> <entry></entry> <entry>Zero if the index offers no sort order, otherwise the strategy number of the strategy operator that describes the sort order</entry> </row> <row> <entry><structfield>amcanunique</structfield></entry> <entry><type>bool</type></entry> <entry></entry> <entry>Does the access method support unique indexes?</entry> </row> <row> <entry><structfield>amcanmulticol</structfield></entry> <entry><type>bool</type></entry> <entry></entry> <entry>Does the access method support multicolumn indexes?</entry> </row> <row> <entry><structfield>amoptionalkey</structfield></entry> <entry><type>bool</type></entry> <entry></entry> <entry>Does the access method support a scan without any constraint for the first index column?</entry> </row> <row> <entry><structfield>amindexnulls</structfield></entry> <entry><type>bool</type></entry> <entry></entry> <entry>Does the access method support null index entries?</entry> </row> <row> <entry><structfield>amconcurrent</structfield></entry> <entry><type>bool</type></entry> <entry></entry> <entry>Does the access method support concurrent updates?</entry> </row> <row> <entry><structfield>aminsert</structfield></entry> <entry><type>regproc</type></entry>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -