System CatalogsOverview
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.
PostgreSQL'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, CREATE
DATABASE inserts a row into the
pg_database catalog -- and actually
creates the database on disk.) There are some exceptions for
especially esoteric operations, such as adding index access methods.
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 an installation;
these are marked in the descriptions of the individual catalogs.
System CatalogsCatalog NamePurposepg_aggregateaggregate functionspg_amindex access methodspg_amopaccess method operatorspg_amprocaccess method support procedurespg_attrdefcolumn default valuespg_attributetable columns (attributes, fields)pg_castcasts (data type conversions)pg_classtables, indexes, sequences (relations)pg_constraintcheck constraints, unique / primary key constraints, foreign key constraintspg_conversionencoding conversion informationpg_databasedatabases within this database clusterpg_dependdependencies between database objectspg_descriptiondescriptions or comments on database objectspg_groupgroups of database userspg_indexadditional index informationpg_inheritstable inheritance hierarchypg_languagelanguages for writing functionspg_largeobjectlarge objectspg_listenerasynchronous notificationpg_namespacenamespaces (schemas)pg_opclassindex access method operator classespg_operatoroperatorspg_procfunctions and procedurespg_rewritequery rewriter rulespg_shadowdatabase userspg_statisticoptimizer statisticspg_triggertriggerspg_typedata types
More detailed documentation of each catalog follows below.
pg_aggregatepg_aggregate 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
sum, count, and
max. Each entry in
pg_aggregate is an extension of an entry
in pg_proc. The pg_proc
entry carries the aggregate's name, input and output datatypes, and
other information that is similar to ordinary functions.
pg_aggregate ColumnsNameTypeReferencesDescriptionaggfnoidregprocpg_proc.oidpg_proc OID of the aggregate functionaggtransfnregprocpg_proc.oidTransition functionaggfinalfnregprocpg_proc.oidFinal function (zero if none)aggtranstypeoidpg_type.oidThe type of the aggregate function's internal transition (state) dataagginitvaltext
The initial value of the transition state. This is a text
field containing the initial value in its external string
representation. If the field is NULL, the transition state
value starts out NULL.
New aggregate functions are registered with the CREATE
AGGREGATE command. See the &cite-programmer; for more
information about writing aggregate functions and the meaning of
the transition functions, etc.
pg_ampg_am stores information about index access
methods. There is one row for each index access method supported by
the system.
pg_am ColumnsNameTypeReferencesDescriptionamnamenamename of the access methodamownerint4pg_shadow.usesysiduser ID of the owner (currently not used)amstrategiesint2number of operator strategies for this access methodamsupportint2number of support routines for this access methodamorderstrategyint2zero if the index offers no sort order, otherwise the strategy
number of the strategy operator that describes the sort orderamcanuniquebooldoes AM support unique indexes?amcanmulticolbooldoes AM support multicolumn indexes?amindexnullsbooldoes AM support NULL index entries?amconcurrentbooldoes AM support concurrent updates?amgettupleregprocpg_proc.oidnext valid tuple functionaminsertregprocpg_proc.oidinsert this tuple functionambeginscanregprocpg_proc.oidstart new scan functionamrescanregprocpg_proc.oidrestart this scan functionamendscanregprocpg_proc.oidend this scan functionammarkposregprocpg_proc.oidmark current scan position functionamrestrposregprocpg_proc.oidrestore marked scan position functionambuildregprocpg_proc.oidbuild new index functionambulkdeleteregprocpg_proc.oidbulk-delete functionamcostestimateregprocpg_proc.oidestimate cost of an indexscan
An index AM that supports multiple columns (has
amcanmulticol true) must>
support indexing nulls in columns after the first, because the planner
will assume the index can be used for queries on just the first
column(s). For example, consider an index on (a,b) and a query
WHERE a = 4. The system will assume the index can be used to scan for
rows with a = 4, which is wrong if the index omits rows where b is null.
However it is okay to omit rows where the first indexed column is null.
(GiST currently does so.)
amindexnulls should be set true only if the
index AM indexes all rows, including arbitrary combinations of nulls.
pg_amoppg_amop stores information about operators
associated with index access method operator classes. There is one
row for each operator that is a member of an operator class.
pg_amop ColumnsNameTypeReferencesDescriptionamopclaidoidpg_opclass.oidthe index opclass this entry is foramopstrategyint2operator strategy numberamopreqcheckboolindex hit must be recheckedamopoproidpg_operator.oidthe operator's pg_operator OID
pg_amprocpg_amproc stores information about support
procedures
associated with index access method operator classes. There is one
row for each support procedure belonging to an operator class.
pg_amproc ColumnsNameTypeReferencesDescriptionamopclaidoidpg_opclass.oidthe index opclass this entry is foramprocnumint2support procedure indexamprocregprocpg_proc.oidOID of the proc
pg_attrdef
This catalog stores column default values. The main information
about columns is stored in pg_attribute
(see below). Only columns that explicitly specify a default value
(when the table is created or the column is added) will have an
entry here.
pg_attrdef ColumnsNameTypeReferencesDescriptionadrelidoidpg_class.oidThe table this column belongs toadnumint2pg_attribute.attnumThe number of the columnadbintextAn internal representation of the column default valueadsrctextA human-readable representation of the default value
pg_attributepg_attribute stores information about
table columns. There will be exactly one
pg_attribute row for every column in every
table in the database. (There will also be attribute entries for
indexes and other objects. See pg_class.)
The term attribute is equivalent to column and is used for
historical reasons.
pg_attribute ColumnsNameTypeReferencesDescriptionattrelidoidpg_class.oidThe table this column belongs toattnamenameColumn nameatttypidoidpg_type.oidThe data type of this columnattstattargetint4attstattarget controls the level of detail
of statistics accumulated for this column by
ANALYZE.
A zero value indicates that no statistics should be collected.
A negative value says to use the system default statistics target.
The exact meaning of positive values is datatype-dependent.
For scalar datatypes, attstattarget
is both the target number of most common values
to collect, and the target number of histogram bins to create.
attlenint2
This is a copy of
pg_type.typlen
of this column's type.
attnumint2
The number of the column. Ordinary columns are numbered from 1
up. System columns, such as oid,
have (arbitrary) negative numbers.
attndimsint4
Number of dimensions, if the column is an array type; otherwise 0.
(Presently, the number of dimensions of an array is not enforced,
so any nonzero value effectively means it's an array>.)
attcacheoffint4
Always -1 in storage, but when loaded into a tuple descriptor
in memory this may be updated to cache the offset of the attribute
within the tuple.
atttypmodint4atttypmod records type-specific data
supplied at table creation time (for example, the maximum
length of a varchar column). It is passed to
type-specific input functions and length coercion functions.
The value will generally be -1 for types that do not need typmod.
attbyvalbool
A copy of
pg_type.typbyval
of this column's type
attstoragechar
Normally a copy of
pg_type.typstorage
of this column's type. For TOASTable datatypes, this can be altered
after column creation to control storage policy.
attissetbool
If true, this attribute is a set. In that case, what is really
stored in the attribute is the OID of a tuple in the
pg_proc catalog. The
pg_proc tuple contains the query
string that defines this set - i.e., the query to run to get
the set. So the atttypid (see
above) refers to the type returned by this query, but the
actual length of this attribute is the length (size) of an
oid. --- At least this is the theory. All this
is probably quite broken these days.
attalignchar
A copy of
pg_type.typalign
of this column's type
attnotnullbool
This represents a NOT NULL constraint. It is possible to
change this field to enable or disable the constraint.
atthasdefbool
This column has a default value, in which case there will be a
corresponding entry in the pg_attrdef
catalog that actually defines the value.
attisdroppedbool
This column has been dropped and is no longer valid. A dropped
column is still physically present in the table, but is
ignored by the parser and so cannot be accessed via SQL.
attislocalbool
This column is defined locally in the relation. Note that a column may
be locally defined and inherited simultaneously.
attinhcountint4
The number of direct ancestors this column has. A column with a
nonzero number of ancestors cannot be dropped nor renamed.
pg_castpg_cast stores data type conversion paths,
both built-in paths and those defined with CREATE CAST.
pg_cast ColumnsNameTypeReferencesDescriptioncastsourceoidpg_type.oidOID of the source data typecasttargetoidpg_type.oidOID of the target data typecastfuncoidpg_proc.oid
The OID of the function to use to perform this cast. Zero is
stored if the data types are binary coercible (that is, no
run-time operation is needed to perform the cast).
castcontextchar
Indicates what contexts the cast may be invoked in.
e> means only as an explicit cast (using
CAST>, ::>, or function-call syntax).
a> means implicitly in assignment
to a target column, as well as explicitly.
i> means implicitly in expressions, as well as the
other cases.
pg_classpg_class catalogs tables and most
everything else that has columns or is otherwise similar to a
table. This includes indexes (but see also
pg_index), sequences, views, and some
kinds of special relation; see relkind>.
Below, when we mean all of these
kinds of objects we speak of relations. Not all
fields are meaningful for all relation types.
pg_class ColumnsNameTypeReferencesDescriptionrelnamenameName of the table, index, view, etc.relnamespaceoidpg_namespace.oid
The OID of the namespace that contains this relation
reltypeoidpg_type.oid
The OID of the data type that corresponds to this table, if any
(zero for indexes, which have no pg_type entry)
relownerint4pg_shadow.usesysidOwner of the relationrelamoidpg_am.oidIf this is an index, the access method used (B-tree, hash, etc.)relfilenodeoidName of the on-disk file of this relation; 0 if nonerelpagesint4
Size of the on-disk representation of this table in pages (size
BLCKSZ).
This is only an estimate used by the planner.
It is updated by VACUUM,
ANALYZE, and CREATE INDEX.
reltuplesfloat4
Number of tuples in the table.
This is only an estimate used by the planner.
It is updated by VACUUM,
ANALYZE, and CREATE INDEX.
reltoastrelidoidpg_class.oid
OID of the TOAST table associated with this table, 0 if none.
The TOAST table stores large attributes out of
line in a secondary table.
reltoastidxidoidpg_class.oid
For a TOAST table, the OID of its index. 0 if not a TOAST table.
relhasindexbool
True if this is a table and it has (or recently had) any
indexes. This is set by CREATE INDEX, but
not cleared immediately by DROP INDEX.
VACUUM clears relhasindex if it finds the
table has no indexes.
relissharedboolTrue if this table is shared across all databases in the
cluster. Only certain system catalogs (such as
pg_database) are shared.relkindchar
'r' = ordinary table, 'i' = index, 'S' = sequence, 'v' = view,
'c' = composite type, 's' = special, 't' = TOAST table
relnattsint2
Number of user columns in the relation (system columns not counted).
There must be this many corresponding entries in
pg_attribute. See also
pg_attribute.attnum.
relchecksint2
Number of check constraints on the table; see
pg_constraint catalog
reltriggersint2
Number of triggers on the table; see
pg_trigger catalog
relukeysint2unused (Not the number of unique keys)relfkeysint2unused (Not the number of foreign keys on the table)relrefsint2unusedrelhasoidsbool
True if we generate an OID for each row of the relation.
relhaspkeybool
True if the table has (or once had) a primary key.
relhasrulesboolTable has rules; see
pg_rewrite catalog
relhassubclassboolAt least one table inherits from this onerelaclaclitem[]
Access permissions. See the descriptions of
GRANT and REVOKE for
details.
pg_constraint
This system catalog stores CHECK, PRIMARY KEY, UNIQUE, and FOREIGN KEY
constraints on tables. (Column
constraints are not treated specially. Every column constraint is
equivalent to some table constraint.) See under CREATE
TABLE for more information.
NOT NULL constraints are represented in the pg_attribute>
catalog.
CHECK constraints on domains are stored here, too. Global ASSERTIONS
(a currently-unsupported SQL feature) may someday appear here as well.
pg_constraint ColumnsNameTypeReferencesDescriptionconnamenameConstraint name (not necessarily unique!)connamespaceoidpg_namespace.oid
The OID of the namespace that contains this constraint
contypechar
'c' = check constraint,
'f' = foreign key constraint,
'p' = primary key constraint,
'u' = unique constraint
condeferrablebooleanIs the constraint deferrable?condeferredbooleanIs the constraint deferred by default?conrelidoidpg_class.oidThe table this constraint is on; 0 if not a table constraintcontypidoidpg_type.oidThe domain this constraint is on; 0 if not a domain constraintconfrelidoidpg_class.oidIf a foreign key, the referenced table; else 0confupdtypecharForeign key update action codeconfdeltypecharForeign key deletion action codeconfmatchtypecharForeign key match typeconkeyint2[]pg_attribute.attnumIf a table constraint, list of columns which the constraint constrainsconfkeyint2[]pg_attribute.attnumIf a foreign key, list of the referenced columnsconbintextIf a check constraint, an internal representation of the expressionconsrctextIf a check constraint, a human-readable representation of the expression
pg_class.relchecks
needs to agree with the number of check-constraint entries found in this
table for the given relation.
pg_conversion
This system catalog stores encoding conversion information. See
CREATE CONVERSION for more information.
pg_conversion ColumnsNameTypeReferencesDescriptionconnamenameConversion name (unique within a namespace)connamespaceoidpg_namespace.oid
The OID of the namespace that contains this conversion
conownerint4pg_shadow.usesysidOwner (creator) of the namespaceconforencodingint4Source(for) encoding IDcontoencodingint4Destination(to) encoding IDconprocregprocpg_proc.oidConversion procedurecondefaultbooleantrue if this is the default conversion
pg_database
The pg_database catalog stores information
about the available databases. Databases are created with the
CREATE DATABASE command. Consult the
&cite-admin; 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.
pg_database ColumnsNameTypeReferencesDescriptiondatnamenameDatabase namedatdbaint4pg_shadow.usesysidOwner of the database, usually the user who created itencodingint4Character/multibyte encoding for this databasedatistemplatebool
If true then this database can be used in the
TEMPLATE clause of CREATE
DATABASE to create a new database as a clone of
this one.
datallowconnbool
If false then no one can connect to this database. This is
used to protect the template0 database from being altered.
datlastsysoidoid
Last system OID in the database; useful
particularly to pg_dumpdatvacuumxidxid
All tuples inserted or deleted by transaction IDs before this one
have been marked as known committed or known aborted in this database.
This is used to determine when commit-log space can be recycled.
datfrozenxidxid
All tuples inserted by transaction IDs before this one have been
relabeled with a permanent (frozen>) transaction ID in this
database. This is useful to check whether a database must be vacuumed
soon to avoid transaction ID wraparound problems.
datpathtext
If the database is stored at an alternative location then this
records the location. It's either an environment variable name
or an absolute path, depending how it was entered.
datconfigtext[]Session defaults for run-time configuration variablesdataclaclitem[]Access permissions
pg_depend
The pg_depend table records the dependency
relationships between database objects. This information allows
DROP> commands to find which other objects must be dropped
by DROP CASCADE>, or prevent dropping in the DROP
RESTRICT> case.
pg_depend ColumnsNameTypeReferencesDescriptionclassidoidpg_class.oidThe oid of the system catalog the dependent object is inobjidoidany oid attributeThe oid of the specific dependent objectobjsubidint4For a table attribute, this is the attribute's
column number (the objid and classid refer to the table itself).
For all other object types, this field is presently zero.
refclassidoidpg_class.oidThe oid of the system catalog the referenced object is inrefobjidoidany oid attributeThe oid of the specific referenced objectrefobjsubidint4For a table attribute, this is the attribute's
column number (the refobjid and refclassid refer to the table itself).
For all other object types, this field is presently zero.
deptypechar
A code defining the specific semantics of this dependency relationship.
In all cases, a pg_depend entry indicates that the
referenced object may not be dropped without also dropping the dependent
object. However, there are several subflavors identified by
deptype>:
DEPENDENCY_NORMAL ('n'): normal relationship between separately-created
objects. The dependent object may be dropped without affecting the
referenced object. The referenced object may only be dropped by
specifying CASCADE, in which case the dependent object is dropped too.
Example: a table column has a normal dependency on its datatype.
DEPENDENCY_AUTO ('a'): the dependent object can be dropped separately
from the referenced object, and should be automatically dropped
(regardless of RESTRICT or CASCADE mode) if the referenced object
is dropped.
Example: a named constraint on a table is made auto-dependent on
the table, so that it will go away if the table is dropped.
DEPENDENCY_INTERNAL ('i'): the dependent object was created as part
of creation of the referenced object, and is really just a part of
its internal implementation. A DROP of the dependent object will be
disallowed outright (we'll tell the user to issue a DROP against the
referenced object, instead). A DROP of the referenced object will be
propagated through to drop the dependent object whether CASCADE is
specified or not.
Example: a trigger that's created to enforce a foreign-key constraint
is made internally dependent on the constraint's pg_constraint entry.
DEPENDENCY_PIN ('p'): there is no dependent object; this type of entry
is a signal that the system itself depends on the referenced object,
and so that object must never be deleted. Entries of this type are
created only during initdb. The fields for the dependent object
contain zeroes.
Other dependency flavors may be needed in future.
pg_description
The pg_description table can store an optional description or
comment for each database object. Descriptions can be manipulated
with the COMMENT command and viewed with
psql's \d commands.
Descriptions of many built-in system objects are provided in the initial
contents of pg_description.
pg_description ColumnsNameTypeReferencesDescriptionobjoidoidany oid attributeThe oid of the object this description pertains toclassoidoidpg_class.oidThe oid of the system catalog this object appears inobjsubidint4For a comment on a table attribute, this is the attribute's
column number (the objoid and classoid refer to the table itself).
For all other object types, this field is presently zero.
descriptiontextArbitrary text that serves as the description of this object.
pg_group
This catalog defines groups and stores what users belong to what
groups. Groups are created with the CREATE
GROUP command. Consult the &cite-admin; for information
about user permission management.
Because user and group identities are cluster-wide,
pg_group
is shared across all databases of a cluster: there is only one
copy of pg_group per cluster, not
one per database.
pg_group ColumnsNameTypeReferencesDescriptiongronamenameName of the groupgrosysidint4An arbitrary number to identify this groupgrolistint4[]pg_shadow.usesysidAn array containing the ids of the users in this group
pg_indexpg_index contains part of the information
about indexes. The rest is mostly in
pg_class.
pg_index ColumnsNameTypeReferencesDescriptionindexrelidoidpg_class.oidThe OID of the pg_class entry for this indexindrelidoidpg_class.oidThe OID of the pg_class entry for the table this index is forindprocregprocpg_proc.oidThe function's OID if this is a functional index,
else zeroindkeyint2vectorpg_attribute.attnum
This is a vector (array) of up to
INDEX_MAX_KEYS values that indicate which
table columns this index pertains to. For example a value of
1 3 would mean that the first and the third
column make up the index key. For a functional index, these
columns are the inputs to the function, and the function's return
value is the index key.
indclassoidvectorpg_opclass.oid
For each column in the index key this contains a reference to
the operator class to use. See
pg_opclass for details.
indisclusteredboolIf true, the table was last clustered on this index.indisuniqueboolIf true, this is a unique index.indisprimaryboolIf true, this index represents the primary key of the table.
(indisunique should always be true when this is true.)indreferenceoidunusedindpredtextExpression tree (in the form of a nodeToString representation)
for partial index predicate. Empty string if not a partial
index.
pg_inherits
This catalog records information about table inheritance hierarchies.
pg_inherits ColumnsNameTypeReferencesDescriptioninhrelidoidpg_class.oid
The OID of the child table.
inhparentoidpg_class.oid
The OID of the parent table.
inhseqnoint4
If there is more than one parent for a child table (multiple
inheritance), this number tells the order in which the
inherited columns are to be arranged. The count starts at 1.
pg_languagepg_language registers call interfaces or
languages in which you can write functions or stored procedures.
See under CREATE LANGUAGE and in the
&cite-programmer; for more information about language handlers.
pg_language ColumnsNameTypeReferencesDescriptionlannamenameName of the language (to be specified when creating a function)lanisplbool
This is false for internal languages (such as
SQL) and true for user-defined languages.
Currently, pg_dump still uses this
to determine which languages need to be dumped, but this may be
replaced by a different mechanism sometime.
lanpltrustedbool
This is a trusted language. See under CREATE
LANGUAGE what this means. If this is an internal
language (lanispl is false) then
this field is meaningless.
lanplcallfoidoidpg_proc.oid
For non-internal languages this references the language
handler, which is a special function that is responsible for
executing all functions that are written in the particular
language.
lanvalidatoroidpg_proc.oid
This references a language validator function that is responsible
for checking the syntax and validity of new functions when they
are created. See under CREATE LANGUAGE for
further information about validators.
lanaclaclitem[]Access permissions
pg_largeobjectpg_largeobject holds the data making up
large objects. A large object is identified by an
OID assigned when it is created. Each large object is broken into
segments or pages> small enough to be conveniently stored as rows
in pg_largeobject.
The amount of data per page is defined to be LOBLKSIZE (which is currently
BLCKSZ/4, or typically 2Kbytes).
pg_largeobject ColumnsNameTypeReferencesDescriptionloidoidIdentifier of the large object that includes this pagepagenoint4Page number of this page within its large object
(counting from zero)databytea
Actual data stored in the large object.
This will never be more than LOBLKSIZE bytes, and may be less.
Each row of pg_largeobject holds data
for one page of a large object, beginning at
byte offset (pageno * LOBLKSIZE) within the object. The implementation
allows sparse storage: pages may be missing, and may be shorter than
LOBLKSIZE bytes even if they are not the last page of the object.
Missing regions within a large object read as zeroes.
pg_listenerpg_listener supports the LISTEN>
and NOTIFY> commands. A listener creates an entry in
pg_listener for each notification name
it is listening for. A notifier scans pg_listener
and updates each matching entry to show that a notification has occurred.
The notifier also sends a signal (using the PID recorded in the table)
to awaken the listener from sleep.
pg_listener ColumnsNameTypeReferencesDescriptionrelnamenameNotify condition name. (The name need not match any actual
relation in the database; the term relname> is historical.)
listenerpidint4PID of the backend process that created this entry.notificationint4
Zero if no event is pending for this listener. If an event is
pending, the PID of the backend that sent the notification.
pg_namespace
A namespace is the structure underlying SQL92 schemas: each namespace
can have a separate collection of relations, types, etc without name
conflicts.
pg_namespace ColumnsNameTypeReferencesDescriptionnspnamenameName of the namespacenspownerint4pg_shadow.usesysidOwner (creator) of the namespacenspaclaclitem[]Access permissions
pg_opclasspg_opclass defines
index access method operator classes. Each operator class defines
semantics for index columns of a particular datatype and a particular
index access method. Note that there can be multiple operator classes
for a given datatype/access method combination, thus supporting multiple
behaviors.
Operator classes are described at length in the &cite-programmer;.
pg_opclass ColumnsNameTypeReferencesDescriptionopcamidoidpg_am.oidindex access method opclass is foropcnamenamename of this opclassopcnamespaceoidpg_namespace.oidnamespace of this opclassopcownerint4pg_shadow.usesysidopclass owneropcintypeoidpg_type.oidtype of input data for opclassopcdefaultbooltrue if opclass is default for opcintypeopckeytypeoidpg_type.oidtype of index data, or zero if same as opcintype
The majority of the information defining an operator class is actually
not in its pg_opclass row, but in the associated
rows in pg_amop and
pg_amproc. Those rows are considered to be
part of the operator class definition --- this is not unlike the way
that a relation is defined by a single pg_class
row, plus associated rows in pg_attribute and
other tables.
pg_operator
See CREATE OPERATOR and the &cite-programmer;
for details on these operator parameters.
pg_operator ColumnsNameTypeReferencesDescriptionoprnamenameName of the operatoroprnamespaceoidpg_namespace.oid
The OID of the namespace that contains this operator
oprownerint4pg_shadow.usesysidOwner (creator) of the operatoroprkindchar
'b' = infix (both), 'l' = prefix
(left), 'r' = postfix (right)
oprcanhashboolThis operator supports hash joins.oprleftoidpg_type.oidType of the left operandoprrightoidpg_type.oidType of the right operandoprresultoidpg_type.oidType of the resultoprcomoidpg_operator.oidCommutator of this operator, if anyoprnegateoidpg_operator.oidNegator of this operator, if anyoprlsortopoidpg_operator.oid
If this operator supports merge joins, the operator that sorts
the type of the left-hand operand (L<L>)
oprrsortopoidpg_operator.oid
If this operator supports merge joins, the operator that sorts
the type of the right-hand operand (R<R>)
oprltcmpopoidpg_operator.oid
If this operator supports merge joins, the less-than operator that
compares the left and right operand types (L<R>)
oprgtcmpopoidpg_operator.oid
If this operator supports merge joins, the greater-than operator that
compares the left and right operand types (L>R>)
oprcoderegprocpg_proc.oidFunction that implements this operatoroprrestregprocpg_proc.oidRestriction selectivity estimation function for this operatoroprjoinregprocpg_proc.oidJoin selectivity estimation function for this operator
Unused fields contain zeroes, for example oprleft is zero for a
prefix operator.
pg_proc
This catalog stores information about functions (or procedures).
The description of CREATE FUNCTION and the
&cite-programmer; contain more information about the meaning of
some fields.
The table contains data for aggregate functions as well as plain functions.
If proisagg is true, there should be a matching
row in pg_aggregate.
pg_proc ColumnsNameTypeReferencesDescriptionpronamenameName of the functionpronamespaceoidpg_namespace.oid
The OID of the namespace that contains this function
proownerint4pg_shadow.usesysidOwner (creator) of the functionprolangoidpg_language.oidImplementation language or call interface of this functionproisaggboolFunction is an aggregate functionprosecdefboolFunction is a security definer (i.e., a setuid>
function)proisstrictbool
Function returns null if any call argument is null. In that
case the function won't actually be called at all. Functions
that are not strict must be prepared to handle
null inputs.
proretsetboolFunction returns a set (ie, multiple values of the specified
data type)provolatilecharprovolatile tells whether the function's
result depends only on its input arguments, or is affected by outside
factors.
It is i for immutable> functions,
which always deliver the same result for the same inputs.
It is s for stable> functions,
whose results (for fixed inputs) do not change within a scan.
It is v for volatile> functions,
whose results may change at any time. (Use v also
for functions with side-effects, so that calls to them cannot get
optimized away.)
pronargsint2Number of argumentsprorettypeoidpg_type.oidData type of the return valueproargtypesoidvectorpg_type.oidA vector with the data types of the function argumentsprosrctext
This tells the function handler how to invoke the function. It
might be the actual source code of the function for interpreted
languages, a link symbol, a file name, or just about anything
else, depending on the implementation language/call convention.
probinbyteaAdditional information about how to invoke the function.
Again, the interpretation is language-specific.
proaclaclitem[]Access permissions
Currently, prosrc contains the function's C-language name (link symbol)
for compiled functions, both built-in and dynamically loaded. For all
other language types, prosrc contains the function's source text.
Currently, probin is unused except for dynamically-loaded C functions,
for which it gives the name of the shared library file containing the
function.
pg_rewrite
This system catalog stores rewrite rules for tables and views.
pg_rewrite ColumnsNameTypeReferencesDescriptionrulenamenameRule nameev_classoidpg_class.oidThe table this rule is forev_attrint2The column this rule is for (currently, always zero to
indicate the whole table)ev_typecharEvent type that the rule is for: '1' = SELECT,
'2' = UPDATE, '3' = INSERT, '4' = DELETEis_insteadboolTrue if the rule is an INSTEAD ruleev_qualtextExpression tree (in the form of a nodeToString representation)
for the rule's qualifying conditionev_actiontextQuery tree (in the form of a nodeToString representation)
for the rule's action
pg_class.relhasrules
must be true if a table has any rules in this catalog.
pg_shadowpg_shadow contains information about
database users. The name stems from the fact that this table
should not be readable by the public since it contains passwords.
pg_user is a publicly readable view on
pg_shadow that blanks out the password field.
The &cite-admin; contains detailed information about user and
permission management.
Because user identities are cluster-wide,
pg_shadow
is shared across all databases of a cluster: there is only one
copy of pg_shadow per cluster, not
one per database.
pg_shadow ColumnsNameTypeReferencesDescriptionusenamenameUser nameusesysidint4User id (arbitrary number used to reference this user)usecreatedbboolUser may create databasesusesuperboolUser is a superuserusecatupdbool
User may update system catalogs. (Even a superuser may not do
this unless this attribute is true.)
passwdtextPasswordvaluntilabstimeAccount expiry time (only used for password authentication)useconfigtext[]Session defaults for run-time configuration variables
pg_statisticpg_statistic stores statistical data about
the contents of the database. Entries are created by
ANALYZE and subsequently used by the query planner.
There is one entry for each table column that has been analyzed.
Note that all the statistical data is inherently approximate,
even assuming that it is up-to-date.
Since different kinds of statistics may be appropriate for different
kinds of data, pg_statistic is designed not
to assume very much about what sort of statistics it stores. Only
extremely general statistics (such as NULL-ness) are given dedicated
columns in pg_statistic. Everything else
is stored in slots, which are groups of associated columns whose
content is identified by a code number in one of the slot's columns.
For more information see
src/include/catalog/pg_statistic.h.
pg_statistic should not be readable by the
public, since even statistical information about a table's contents
may be considered sensitive. (Example: minimum and maximum values
of a salary column might be quite interesting.)
pg_stats is a publicly readable view on
pg_statistic that only exposes information
about those tables that are readable by the current user.
pg_stats is also designed to present the
information in a more readable format than the underlying
pg_statistic table --- at the cost that
its schema must be extended whenever new slot types are added.
pg_statistic ColumnsNameTypeReferencesDescriptionstarelidoidpg_class.oidThe table that the described column belongs tostaattnumint2pg_attribute.attnumThe number of the described columnstanullfracfloat4The fraction of the column's entries that are NULLstawidthint4The average stored width, in bytes, of non-NULL entriesstadistinctfloat4The number of distinct non-NULL data values in the column.
A value greater than zero is the actual number of distinct values.
A value less than zero is the negative of a fraction of the number
of rows in the table (for example, a column in which values appear about
twice on the average could be represented by stadistinct = -0.5).
A zero value means the number of distinct values is unknown.
stakindNint2A code number indicating the kind of statistics stored in the Nth
slot of the pg_statistic row.
staopNoidpg_operator.oidAn operator used to derive the statistics stored in the
Nth slot. For example, a histogram slot would show the <
operator that defines the sort order of the data.
stanumbersNfloat4[]Numerical statistics of the appropriate kind for the Nth
slot, or NULL if the slot kind does not involve numerical values.
stavaluesNtext[]Column data values of the appropriate kind for the Nth
slot, or NULL if the slot kind does not store any data values.
For data-type independence, all column data values are converted
to external textual form and stored as TEXT datums.
pg_trigger
This system catalog stores triggers on tables. See under
CREATE TRIGGER for more information.
pg_trigger ColumnsNameTypeReferencesDescriptiontgrelidoidpg_class.oidThe table this trigger is ontgnamenameTrigger name (must be unique among triggers of same table)tgfoidoidpg_proc.oidThe function to be calledtgtypeint2Bitmask identifying trigger conditionstgenabledboolTrue if trigger is enabled (not presently checked everywhere
it should be, so disabling a trigger by setting this false does not
work reliably)tgisconstraintboolTrue if trigger implements an RI constrainttgconstrnamenameRI constraint nametgconstrrelidoidpg_class.oidThe table referenced by an RI constrainttgdeferrableboolTrue if deferrabletginitdeferredboolTrue if initially deferredtgnargsint2Number of argument strings passed to trigger functiontgattrint2vectorCurrently unusedtgargsbyteaArgument strings to pass to trigger, each null-terminated
pg_class.reltriggers
needs to match up with the entries in this table.
pg_type
This catalog stores information about data types. Scalar types
(base types>) are created with CREATE TYPE.
A complex type is automatically created for each table in the database, to
represent the row structure of the table. It is also possible to create
complex types with CREATE TYPE AS, and
derived types with CREATE DOMAIN.
pg_type ColumnsNameTypeReferencesDescriptiontypnamenameData type nametypnamespaceoidpg_namespace.oid
The OID of the namespace that contains this type
typownerint4pg_shadow.usesysidOwner (creator) of the typetyplenint2
For a fixed-size type, typlen is the number
of bytes in the internal representation of the type. But for a
variable-length type, typlen is negative.
-1 indicates a varlena> type (one that has a length word),
-2 indicates a null-terminated C string.
typbyvalbooltypbyval determines whether internal
routines pass a value of this type by value or by reference.
Only char, short, and
int equivalent items can be passed by value, so if
the type is not 1, 2, or 4 bytes long,
PostgreSQL> does not have
the option of passing by value and so
typbyval had better be false.
Variable-length types are always passed by reference. Note that
typbyval can be false even if the
length would allow pass-by-value; this is currently true for
type float4, for example.
typtypechartyptype is b for
a base type, c for a complex type (i.e.,
a table's row type), d for a derived type (i.e.,
a domain), or p for a pseudo-type. See also
typrelid
and typbasetype.
typisdefinedboolTrue if the type is defined, false if this is a placeholder
entry for a not-yet-defined type. When typisdefined is false,
nothing except the type name, namespace, and OID can be relied on.
typdelimcharCharacter that separates two values of this type when parsing
array input. Note that the delimiter is associated with the array
element data type, not the array data type.typrelidoidpg_class.oid
If this is a complex type (see
typtype), then this field points to
the pg_class entry that defines the
corresponding table. (For a free-standing composite type, the
pg_class entry doesn't really represent
a table, but it is needed anyway for the type's
pg_attribute entries to link to.)
Zero for non-complex types.
typelemoidpg_type.oid
If typelem is not 0 then it
identifies another row in pg_type.
The current type can then be subscripted like an array yielding
values of type typelem. A
true array type is variable length
(typlen = -1),
but some fixed-length (typlen > 0) types
also have nonzero typelem, for example
name and oidvector.
If a fixed-length type has a typelem then
its internal representation must be N values of the
typelem data type with no other data.
Variable-length array types have a header defined by the array
subroutines.
typinputregprocpg_proc.oidInput conversion functiontypoutputregprocpg_proc.oidOutput conversion functiontypalignchartypalign is the alignment required
when storing a value of this type. It applies to storage on
disk as well as most representations of the value inside
PostgreSQL>.
When multiple values are stored consecutively, such
as in the representation of a complete row on disk, padding is
inserted before a datum of this type so that it begins on the
specified boundary. The alignment reference is the beginning
of the first datum in the sequence.
Possible values are:
'c' = CHAR alignment, i.e., no alignment needed.'s' = SHORT alignment (2 bytes on most machines).'i' = INT alignment (4 bytes on most machines).'d' = DOUBLE alignment (8 bytes on many machines, but by no means all).
For types used in system tables, it is critical that the size
and alignment defined in pg_type
agree with the way that the compiler will lay out the field in
a struct representing a table row.
typstoragechartypstorage tells for varlena
types (those with typlen = -1) if
the type is prepared for toasting and what the default strategy
for attributes of this type should be.
Possible values are
'p': Value must always be stored plain.
'e': Value can be stored in a secondary
relation (if relation has one, see
pg_class.reltoastrelid).
'm': Value can be stored compressed inline.'x': Value can be stored compressed inline or in secondary.
Note that 'm' fields can also be moved out to secondary
storage, but only as a last resort ('e' and 'x' fields are
moved first).
typnotnullbooltypnotnull represents a NOT NULL
constraint on a type. Presently used for domains only.
typbasetypeoidpg_type.oid
If this is a derived type (see typtype),
then typbasetype identifies
the type that this one is based on. Zero if not a derived type.
typtypmodint4
Domains use typtypmod to record the typmod
to be applied to their base type (-1 if base type does not use a
typmod). -1 if this type is not a domain.
typndimsint4typndims is the number of array dimensions
for a domain that is an array (that is, typbasetype is an array type;
the domain's typelem will match the base type's typelem).
Zero for non-domains and non-array domains.
typdefaultbintext
If typdefaultbin> is not NULL, it is the nodeToString
representation of a default expression for the type. Currently this is
only used for domains.
typdefaulttexttypdefault> is NULL if the type has no associated
default value. If typdefaultbin> is not NULL,
typdefault> must contain a human-readable version of the
default expression represented by typdefaultbin>. If
typdefaultbin> is NULL and typdefault> is
not, then typdefault> is the external representation of
the type's default value, which may be fed to the type's input
converter to produce a constant.