System Catalogs
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
particularly esoteric operations, such as adding index access methods.
Overview lists the system catalogs.
More detailed documentation of each catalog follows below.
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.
System CatalogsCatalog NamePurposepg_aggregateaggregate functionspg_amindex access methodspg_amopaccess method operatorspg_amprocaccess method support procedurespg_attrdefcolumn default valuespg_attributetable columns (attributes)pg_authidauthorization identifiers (roles)pg_auth_membersauthorization identifier membership relationshipspg_castcasts (data type conversions)pg_classtables, indexes, sequences, views (relations)pg_constraintcheck constraints, unique constraints, primary key constraints, foreign key constraintspg_conversionencoding conversion informationpg_databasedatabases within this database clusterpg_default_acldefault privileges for object typespg_dependdependencies between database objectspg_descriptiondescriptions or comments on database objectspg_enumenum label and value definitionspg_foreign_data_wrapperforeign-data wrapper definitionspg_foreign_serverforeign server definitionspg_indexadditional index informationpg_inheritstable inheritance hierarchypg_languagelanguages for writing functionspg_largeobjectdata pages for large objectspg_largeobject_metadatametadata for large objectspg_namespaceschemaspg_opclassaccess method operator classespg_operatoroperatorspg_opfamilyaccess method operator familiespg_pltemplatetemplate data for procedural languagespg_procfunctions and procedurespg_rewritequery rewrite rulespg_db_role_settingper-role and per-database settingspg_shdependdependencies on shared objectspg_shdescriptioncomments on shared objectspg_statisticplanner statisticspg_tablespacetablespaces within this database clusterpg_triggertriggerspg_ts_configtext search configurationspg_ts_config_maptext search configurations' token mappingspg_ts_dicttext search dictionariespg_ts_parsertext search parserspg_ts_templatetext search templatespg_typedata typespg_user_mappingmappings of users to foreign servers
pg_aggregatepg_aggregate
The catalog pg_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 data types, 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)aggsortopoidpg_operator.oidAssociated sort operator (zero if none)aggtranstypeoidpg_type.oidData 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 this field is NULL, the transition state
value starts out NULL
New aggregate functions are registered with the
command. See for more information about
writing aggregate functions and the meaning of the transition
functions, etc.
pg_ampg_am
The catalog pg_am 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
.
pg_am> ColumnsNameTypeReferencesDescriptionamnamenameName of the access methodamstrategiesint2Number of operator strategies for this access method,
or zero if access method does not have a fixed set of operator
strategiesamsupportint2Number of support routines for this access methodamcanorderboolDoes the access method support ordered scans?amcanbackwardboolDoes the access method support backward scanning?amcanuniqueboolDoes the access method support unique indexes?amcanmulticolboolDoes the access method support multicolumn indexes?amoptionalkeyboolDoes the access method support a scan without any constraint
for the first index column?amindexnullsboolDoes the access method support null index entries?amsearchnullsboolDoes the access method support IS NULL/NOT NULL searches?amstorageboolCan index storage data type differ from column data type?amclusterableboolCan an index of this type be clustered on?amkeytypeoidpg_type.oidType of data stored in index, or zero if not a fixed typeaminsertregprocpg_proc.oidInsert this tuple functionambeginscanregprocpg_proc.oidStart new scan functionamgettupleregprocpg_proc.oidNext valid tuple function, or zero if noneamgetbitmapregprocpg_proc.oidFetch all valid tuples function, or zero if noneamrescanregprocpg_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 functionamvacuumcleanupregprocpg_proc.oidPost-VACUUM cleanup functionamcostestimateregprocpg_proc.oidFunction to estimate cost of an index scanamoptionsregprocpg_proc.oidFunction to parse and validate reloptions> for an index
pg_amoppg_amop
The catalog pg_amop stores information about
operators associated with access method operator families. There is one
row for each operator that is a member of an operator family. An operator
can appear in more than one family, but cannot appear in more than one
position within a family.
pg_amop> ColumnsNameTypeReferencesDescriptionamopfamilyoidpg_opfamily.oidThe operator family this entry is foramoplefttypeoidpg_type.oidLeft-hand input data type of operatoramoprighttypeoidpg_type.oidRight-hand input data type of operatoramopstrategyint2Operator strategy numberamopoproidpg_operator.oidOID of the operatoramopmethodoidpg_am.oidIndex access method operator family is for
An entry's amopmethod> must match the
opfmethod> of its containing operator family (including
amopmethod> here is an intentional denormalization of the
catalog structure for performance reasons). Also,
amoplefttype> and amoprighttype> must match
the oprleft> and oprright> fields of the
referenced pg_operator> entry.
pg_amprocpg_amproc
The catalog pg_amproc stores information about
support procedures associated with access method operator families. There
is one row for each support procedure belonging to an operator family.
pg_amproc ColumnsNameTypeReferencesDescriptionamprocfamilyoidpg_opfamily.oidThe operator family this entry is foramproclefttypeoidpg_type.oidLeft-hand input data type of associated operatoramprocrighttypeoidpg_type.oidRight-hand input data type of associated operatoramprocnumint2Support procedure numberamprocregprocpg_proc.oidOID of the procedure
The usual interpretation of the
amproclefttype> and amprocrighttype> fields
is that they identify the left and right input types of the operator(s)
that a particular support procedure supports. For some access methods
these match the input data type(s) of the support procedure itself, for
others not. There is a notion of default> support procedures for
an index, which are those with amproclefttype> and
amprocrighttype> both equal to the index opclass's
opcintype>.
pg_attrdefpg_attrdef
The catalog pg_attrdef 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 columnadbintextThe internal representation of the column default valueadsrctextA human-readable representation of the default value
The adsrc field is historical, and is best
not used, because it does not track outside changes that might affect
the representation of the default value. Reverse-compiling the
adbin field (with pg_get_expr> for
example) is a better way to display the default value.
pg_attributepg_attribute
The catalog pg_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 indeed all objects that have pg_class
entries.)
The term attribute is equivalent to column and is used for
historical reasons.
pg_attribute> ColumnsNameTypeReferencesDescriptionattrelidoidpg_class.oidThe table this column belongs toattnamenameThe column nameatttypidoidpg_type.oidThe data type of this columnattstattargetint4attstattarget controls the level of detail
of statistics accumulated for this column by
.
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 data type-dependent.
For scalar data types, attstattarget
is both the target number of most common values
to collect, and the target number of histogram bins to create
attlenint2
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 row descriptor
in memory this might be updated to cache the offset of the attribute
within the row
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 atttypmod>
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 TOAST-able data types, this can be altered
after column creation to control storage policy
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 column 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 can
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
attaclaclitem[]
Column-level access privileges, if any have been granted specifically
on this column
attoptionstext[]
Attribute-level options, as keyword=value> strings
In a dropped column's pg_attribute entry,
atttypid is reset to zero, but
attlen and the other fields copied from
pg_type> are still valid. This arrangement is needed
to cope with the situation where the dropped column's data type was
later dropped, and so there is no pg_type> row anymore.
attlen and the other fields can be used
to interpret the contents of a row of the table.
pg_authidpg_authid
The catalog pg_authid contains information about
database authorization identifiers (roles). A role subsumes the concepts
of users> and groups>. A user is essentially just a
role with the rolcanlogin> flag set. Any role (with or
without rolcanlogin>) can have other roles as members; see
pg_auth_members.
Since this catalog contains passwords, it must not be publicly readable.
pg_roles
is a publicly readable view on
pg_authid that blanks out the password field.
contains detailed information about user and
privilege management.
Because user identities are cluster-wide,
pg_authid
is shared across all databases of a cluster: there is only one
copy of pg_authid per cluster, not
one per database.
pg_authid> ColumnsNameTypeDescriptionrolnamenameRole namerolsuperboolRole has superuser privilegesrolinheritboolRole automatically inherits privileges of roles it is a
member ofrolcreateroleboolRole can create more rolesrolcreatedbboolRole can create databasesrolcatupdatebool
Role can update system catalogs directly. (Even a superuser cannot do
this unless this column is true)
rolcanloginbool
Role can log in. That is, this role can be given as the initial
session authorization identifier
rolconnlimitint4
For roles that can log in, this sets maximum number of concurrent
connections this role can make. -1 means no limit
rolpasswordtextPassword (possibly encrypted); NULL if nonerolvaliduntiltimestamptzPassword expiry time (only used for password authentication);
NULL if no expiration
pg_auth_memberspg_auth_members
The catalog pg_auth_members shows the membership
relations between roles. Any non-circular set of relationships is allowed.
Because user identities are cluster-wide,
pg_auth_members
is shared across all databases of a cluster: there is only one
copy of pg_auth_members per cluster, not
one per database.
pg_auth_members> ColumnsNameTypeReferencesDescriptionroleidoidpg_authid.oidID of a role that has a membermemberoidpg_authid.oidID of a role that is a member of roleid>grantoroidpg_authid.oidID of the role that granted this membershipadmin_optionboolTrue if member> can grant membership in
roleid> to others
pg_castpg_cast
The catalog pg_cast stores data type conversion
paths, both built-in paths and those defined with
.
It should be noted that pg_cast does not represent
every type conversion that the system knows how to perform; only those that
cannot be deduced from some generic rule. For example, casting between a
domain and its base type is not explicitly represented in
pg_cast. Another important exception is that
automatic I/O conversion casts>, those performed using a data
type's own I/O functions to convert to or from text> or other
string types, are not explicitly represented in
pg_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 cast method doesn't require a function.
castcontextchar
Indicates what contexts the cast can be invoked in.
e> means only as an explicit cast (using
CAST> or ::> 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
castmethodchar
Indicates how the cast is performed.
f> means that the function specified in the castfunc> field is used.
i> means that the input/output functions are used.
b> means that the types are binary-coercible, thus no conversion is required
The cast functions listed in pg_cast must
always take the cast source type as their first argument type, and
return the cast destination type as their result type. A cast
function can have up to three arguments. The second argument,
if present, must be type integer>; it receives the type
modifier associated with the destination type, or -1>
if there is none. The third argument,
if present, must be type boolean>; it receives true>
if the cast is an explicit cast, false> otherwise.
It is legitimate to create a pg_cast entry
in which the source and target types are the same, if the associated
function takes more than one argument. Such entries represent
length coercion functions> that coerce values of the type
to be legal for a particular type modifier value.
When a pg_cast entry has different source and
target types and a function that takes more than one argument, it
represents converting from one type to another and applying a length
coercion in a single step. When no such entry is available, coercion
to a type that uses a type modifier involves two steps, one to
convert between data types and a second to apply the modifier.
pg_classpg_class
The catalog pg_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, composite types,
and TOAST tables; see relkind>.
Below, when we mean all of these
kinds of objects we speak of relations. Not all
columns 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's row type,
if any (zero for indexes, which have no pg_type> entry)
relowneroidpg_authid.oidOwner 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; zero means this
is a mapped> relation whose disk file name is determined
by low-level statereltablespaceoidpg_tablespace.oid
The tablespace in which this relation is stored. If zero,
the database's default tablespace is implied. (Not meaningful
if the relation has no on-disk file.)
relpagesint4
Size of the on-disk representation of this table in pages (of size
BLCKSZ). This is only an estimate used by the
planner. It is updated by VACUUM,
ANALYZE, and a few DDL commands such as
CREATE INDEXreltuplesfloat4
Number of rows in the table. This is only an estimate used by the
planner. It is updated by VACUUM,
ANALYZE, and a few DDL commands such as
CREATE INDEXreltoastrelidoidpg_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
relissharedbool
True if this table is shared across all databases in the cluster. Only
certain system catalogs (such as pg_database)
are shared
relistempbool
True if this table is a temporary relation. If so, only the creating
session can safely access its contents
relkindcharr> = ordinary table, i> = index,
S> = sequence, v> = view, c> =
composite type, 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.attnumrelchecksint2
Number of CHECK> constraints on the table; see
pg_constraint catalog
relhasoidsbool
True if we generate an OID for each row of the relation
relhaspkeybool
True if the table has (or once had) a primary key
relhasexclusionbool
For a table, true if the table has (or once had) any exclusion
constraints; for an index, true if the index supports an exclusion
constraint
relhasrulesbool
True if table has (or once had) rules; see
pg_rewrite catalog
relhastriggersbool
True if table has (or once had) triggers; see
pg_trigger catalog
relhassubclassboolTrue if table has (or once had) any inheritance childrenrelfrozenxidxid
All transaction IDs before this one have been replaced with a permanent
(frozen>) transaction ID in this table. This is used to track
whether the table needs to be vacuumed in order to prevent transaction
ID wraparound or to allow pg_clog> to be shrunk. Zero
(InvalidTransactionId) if the relation is not a table
relaclaclitem[]
Access privileges; see
and
for details
reloptionstext[]
Access-method-specific options, as keyword=value> strings
Several of the boolean flags in pg_class> are maintained
lazily: they are guaranteed to be true if that's the correct state, but
may not be reset to false immediately when the condition is no longer
true. For example, relhasindex> is set by
CREATE INDEX, but it is never cleared by
DROP INDEX. Instead, VACUUM clears
relhasindex> if it finds the table has no indexes. This
arrangement avoids race conditions and improves concurrency.
pg_constraintpg_constraint
The catalog pg_constraint stores check, primary
key, unique, foreign key, and exclusion constraints on tables.
(Column constraints are not treated specially. Every column constraint is
equivalent to some table constraint.)
Not-null constraints are represented in the pg_attribute>
catalog, not here.
User-defined constraint triggers (created with CREATE CONSTRAINT
TRIGGER>) also give rise to an entry in this table.
Check constraints on domains are stored here, too.
pg_constraint> ColumnsNameTypeReferencesDescriptionconnamenameConstraint name (not necessarily unique!)connamespaceoidpg_namespace.oid
The OID of the namespace that contains this constraint
contypecharc> = check constraint,
f> = foreign key constraint,
p> = primary key constraint,
u> = unique constraint,
t> = constraint trigger,
x> = exclusion constraint
condeferrableboolIs the constraint deferrable?condeferredboolIs 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 constraintconindidoidpg_class.oidThe index supporting this constraint, if it's a unique, primary
key, foreign key, or exclusion constraint; else 0confrelidoidpg_class.oidIf a foreign key, the referenced table; else 0confupdtypecharForeign key update action code:
a> = no action,
r> = restrict,
c> = cascade,
n> = set null,
d> = set default
confdeltypecharForeign key deletion action code:
a> = no action,
r> = restrict,
c> = cascade,
n> = set null,
d> = set default
confmatchtypecharForeign key match type:
f> = full,
p> = partial,
u> = simple (unspecified)
conislocalbool
This constraint is defined locally for the relation. Note that a
constraint can be locally defined and inherited simultaneously
coninhcountint4
The number of direct inheritance ancestors this constraint has.
A constraint with
a nonzero number of ancestors cannot be dropped nor renamed
conkeyint2[]pg_attribute.attnum>If a table constraint (including foreign keys, but not constraint
triggers), list of the constrained columnsconfkeyint2[]pg_attribute.attnum>If a foreign key, list of the referenced columnsconpfeqopoid[]pg_operator.oid>If a foreign key, list of the equality operators for PK = FK comparisonsconppeqopoid[]pg_operator.oid>If a foreign key, list of the equality operators for PK = PK comparisonsconffeqopoid[]pg_operator.oid>If a foreign key, list of the equality operators for FK = FK comparisonsconexclopoid[]pg_operator.oid>If an exclusion constraint, list of the per-column exclusion operatorsconbintextIf a check constraint, an internal representation of the expressionconsrctextIf a check constraint, a human-readable representation of the expression
In the case of an exclusion constraint, conkey
is only useful for constraint elements that are simple column references.
For other cases, a zero appears in conkey
and the associated index must be consulted to discover the expression
that is constrained. (conkey thus has the
same contents as pg_index>.indkey> for the
index.)
consrc is not updated when referenced objects
change; for example, it won't track renaming of columns. Rather than
relying on this field, it's best to use pg_get_constraintdef()>
to extract the definition of a check constraint.
pg_class.relchecks needs to agree with the
number of check-constraint entries found in this table for each
relation. Also, pg_class.relhasexclusion must
be true if there are any exclusion-constraint entries for the relation.
pg_conversionpg_conversion
The catalog pg_conversion describes the
available encoding conversion procedures. See
for more information.
pg_conversion> ColumnsNameTypeReferencesDescriptionconnamenameConversion name (unique within a namespace)connamespaceoidpg_namespace.oid
The OID of the namespace that contains this conversion
conowneroidpg_authid.oidOwner of the conversionconforencodingint4Source encoding IDcontoencodingint4Destination encoding IDconprocregprocpg_proc.oidConversion procedurecondefaultboolTrue if this is the default conversion
pg_databasepg_database
The catalog pg_database stores information about
the available databases. Databases are created with the command.
Consult 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 namedatdbaoidpg_authid.oidOwner of the database, usually the user who created itencodingint4Character encoding for this database
(pg_encoding_to_char() can translate
this number to the encoding name)datcollatenameLC_COLLATE for this databasedatctypenameLC_CTYPE 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
datconnlimitint4
Sets maximum number of concurrent connections that can be made
to this database. -1 means no limit
datlastsysoidoid
Last system OID in the database; useful
particularly to pg_dumpdatfrozenxidxid
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 pg_clog> to be shrunk.
It is the minimum of the per-table
pg_class>.relfrozenxid> values
dattablespaceoidpg_tablespace.oid
The default tablespace for the database.
Within this database, all tables for which
pg_class>.reltablespace> is zero
will be stored in this tablespace; in particular, all the non-shared
system catalogs will be there
dataclaclitem[]
Access privileges; see
and
for details
pg_default_aclpg_default_acl
The catalog pg_default_acl> stores initial
privileges to be assigned to newly created objects.
pg_default_acl> ColumnsNameTypeReferencesDescriptiondefaclroleoidpg_authid.oidThe OID of the role associated with this entrydefaclnamespaceoidpg_namespace.oidThe OID of the namespace associated with this entry,
or 0 if nonedefaclobjtypechar
Type of object this entry is for:
r> = relation (table, view),
S> = sequence,
f> = function
defaclaclaclitem[]
Access privileges that this type of object should have on creation
A pg_default_acl> entry shows the initial privileges to
be assigned to an object belonging to the indicated user. There are
currently two types of entry: global> entries with
defaclnamespace> = 0, and per-schema> entries
that reference a particular schema. If a global entry is present then
it overrides> the normal hard-wired default privileges
for the object type. A per-schema entry, if present, represents privileges
to be added to> the global or hard-wired default privileges.
Note that when an ACL entry in another catalog is NULL, it is taken
to represent the hard-wired default privileges for its object,
not> whatever might be in pg_default_acl>
at the moment. pg_default_acl> is only consulted during
object creation.
pg_dependpg_depend
The catalog pg_depend 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.
See also pg_shdepend,
which performs a similar function for dependencies involving objects
that are shared across a database cluster.
pg_depend> ColumnsNameTypeReferencesDescriptionclassidoidpg_class.oidThe OID of the system catalog the dependent object is inobjidoidany OID columnThe OID of the specific dependent objectobjsubidint4
For a table column, this is the column number (the
objid> and classid> refer to the
table itself). For all other object types, this column is
zero
refclassidoidpg_class.oidThe OID of the system catalog the referenced object is inrefobjidoidany OID columnThe OID of the specific referenced objectrefobjsubidint4
For a table column, this is the column number (the
refobjid> and refclassid> refer
to the table itself). For all other object types, this column
is zero
deptypechar
A code defining the specific semantics of this dependency relationship; see text
In all cases, a pg_depend entry indicates that the
referenced object cannot be dropped without also dropping the dependent
object. However, there are several subflavors identified by
deptype>:
DEPENDENCY_NORMAL> (n>)
A normal relationship between separately-created objects. The
dependent object can be dropped without affecting the
referenced object. The referenced object can 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 data type.
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 autodependent 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 by initdb. The columns for the
dependent object contain zeroes.
Other dependency flavors might be needed in future.
pg_descriptionpg_description
The catalog pg_description> stores optional descriptions
(comments) for each database object. Descriptions can be manipulated
with the command and viewed with
psql's \d commands.
Descriptions of many built-in system objects are provided in the initial
contents of pg_description.
See also pg_shdescription,
which performs a similar function for descriptions involving objects that
are shared across a database cluster.
pg_description> ColumnsNameTypeReferencesDescriptionobjoidoidany OID columnThe OID of the object this description pertains toclassoidoidpg_class.oidThe OID of the system catalog this object appears inobjsubidint4
For a comment on a table column, this is the column number (the
objoid> and classoid> refer to
the table itself). For all other object types, this column is
zero
descriptiontextArbitrary text that serves as the description of this object
pg_enumpg_enum
The pg_enum catalog contains entries
matching enum types to their associated values and labels. The
internal representation of a given enum value is actually the OID
of its associated row in pg_enum. The
OIDs for a particular enum type are guaranteed to be ordered in
the way the type should sort, but there is no guarantee about the
ordering of OIDs of unrelated enum types.
pg_enum> ColumnsNameTypeReferencesDescriptionenumtypidoidpg_type.oidThe OID of the pg_type> entry owning this enum valueenumlabelnameThe textual label for this enum value
pg_foreign_data_wrapperpg_foreign_data_wrapper
The catalog pg_foreign_data_wrapper stores
foreign-data wrapper definitions. A foreign-data wrapper is the
mechanism by which external data, residing on foreign servers, is
accessed.
pg_foreign_data_wrapper> ColumnsNameTypeReferencesDescriptionfdwnamenameName of the foreign-data wrapperfdwowneroidpg_authid.oidOwner of the foreign-data wrapperfdwvalidatoroidpg_proc.oid
References a validator function that is responsible for
checking the validity of the generic options given to the
foreign-data wrapper, as well as to foreign servers and user
mappings using the foreign-data wrapper. Zero if no validator
is provided.
fdwaclaclitem[]
Access privileges; see
and
for details
fdwoptionstext[]
Foreign-data wrapper specific options, as keyword=value> strings
pg_foreign_serverpg_foreign_server
The catalog pg_foreign_server stores
foreign server definitions. A foreign server describes the
connection to a remote server, managing external data. Foreign
servers are accessed via foreign-data wrappers.
pg_foreign_server> ColumnsNameTypeReferencesDescriptionsrvnamenameName of the foreign serversrvowneroidpg_authid.oidOwner of the foreign serversrvfdwoidpg_foreign_data_wrapper.oidThe OID of the foreign-data wrapper of this foreign serversrvtypetextType of the server (optional)srvversiontextVersion of the server (optional)srvaclaclitem[]
Access privileges; see
and
for details
srvoptionstext[]
Foreign server specific options, as keyword=value> strings.
pg_indexpg_index
The catalog pg_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 forindnattsint2The number of columns in the index (duplicates
pg_class.relnatts)indisuniqueboolIf true, this is a unique indexindisprimaryboolIf true, this index represents the primary key of the table
(indisunique> should always be true when this is true)indimmediateboolIf true, the uniqueness check is enforced immediately on insertion
(indisunique> should always be true when this is true)indisclusteredboolIf true, the table was last clustered on this indexindisvalidbool
If true, the index is currently valid for queries. False means the
index is possibly incomplete: it must still be modified by
INSERT>/UPDATE> operations, but it cannot safely
be used for queries. If it is unique, the uniqueness property is not
true either
indcheckxminbool
If true, queries must not use the index until the xmin>
of this pg_index> row is below their TransactionXmin
event horizon, because the table may contain broken HOT chains with
incompatible rows that they can see
indisreadybool
If true, the index is currently ready for inserts. False means the
index must be ignored by INSERT>/UPDATE>
operations
indkeyint2vectorpg_attribute.attnum
This is an array of indnatts values that
indicate which table columns this index indexes. For example a value
of 1 3 would mean that the first and the third table
columns make up the index key. A zero in this array indicates that the
corresponding index attribute is an expression over the table columns,
rather than a simple column reference
indclassoidvectorpg_opclass.oid
For each column in the index key, this contains the OID of
the operator class to use. See
pg_opclass for details
indoptionint2vector
This is an array of indnatts values that
store per-column flag bits. The meaning of the bits is defined by
the index's access method
indexprstextExpression trees (in nodeToString() representation)
for index attributes that are not simple column references. This is a
list with one element for each zero entry in indkey>.
NULL if all index attributes are simple referencesindpredtextExpression tree (in nodeToString() representation)
for partial index predicate. NULL if not a partial index
pg_inheritspg_inherits
The catalog pg_inherits> records information about
table inheritance hierarchies. There is one entry for each direct
child table in the database. (Indirect inheritance can be determined
by following chains of entries.)
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 direct 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
The catalog pg_language registers
languages in which you can write functions or stored procedures.
See
and for more information about language handlers.
pg_language> ColumnsNameTypeReferencesDescriptionlannamenameName of the languagelanowneroidpg_authid.oidOwner of the languagelanisplbool
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 might be
replaced by a different mechanism in the future
lanpltrustedbool
True if this is a trusted language, which means that it is believed
not to grant access to anything outside the normal SQL execution
environment. Only superusers can create functions in untrusted
languages
lanplcallfoidoidpg_proc.oid
For noninternal 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
laninlineoidpg_proc.oid
This references a function that is responsible for executing
inline> anonymous code blocks
( blocks).
Zero if inline blocks are not supported
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. Zero if no validator is provided
lanaclaclitem[]
Access privileges; see
and
for details
pg_largeobjectpg_largeobject
The catalog pg_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 2 kB).
Prior to PostgreSQL> 9.0, there was no permission structure
associated with large objects. As a result,
pg_largeobject was publicly readable and could be
used to obtain the OIDs (and contents) of all large objects in the system.
This is no longer the case; use
pg_largeobject_metadata
to obtain a list of large object OIDs.
pg_largeobject> ColumnsNameTypeReferencesDescriptionloidoidpg_largeobject_metadata.oidIdentifier 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 might 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 might be missing, and might 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_largeobject_metadatapg_largeobject_metadata
The catalog pg_largeobject_metadata
holds metadata associated with large objects. The actual large object
data is stored in
pg_largeobject.
pg_largeobject_metadata> ColumnsNameTypeReferencesDescriptionlomowneroidpg_authid.oidOwner of the largeobjectlomaclaclitem[]
Access privileges; see
and
for details
pg_namespacepg_namespace
The catalog pg_namespace> stores namespaces.
A namespace is the structure underlying SQL schemas: each namespace
can have a separate collection of relations, types, etc. without name
conflicts.
pg_namespace> ColumnsNameTypeReferencesDescriptionnspnamenameName of the namespacenspowneroidpg_authid.oidOwner of the namespacenspaclaclitem[]
Access privileges; see
and
for details
pg_opclasspg_opclass
The catalog pg_opclass defines
index access method operator classes. Each operator class defines
semantics for index columns of a particular data type and a particular
index access method. An operator class essentially specifies that a
particular operator family is applicable to a particular indexable column
data type. The set of operators from the family that are actually usable
with the indexed column are whichever ones accept the column's data type
as their lefthand input.
Operator classes are described at length in .
pg_opclass> ColumnsNameTypeReferencesDescriptionopcmethodoidpg_am.oidIndex access method operator class is foropcnamenameName of this operator classopcnamespaceoidpg_namespace.oidNamespace of this operator classopcowneroidpg_authid.oidOwner of the operator classopcfamilyoidpg_opfamily.oidOperator family containing the operator classopcintypeoidpg_type.oidData type that the operator class indexesopcdefaultboolTrue if this operator class is the default for opcintype>opckeytypeoidpg_type.oidType of data stored in index, or zero if same as opcintype>
An operator class's opcmethod> must match the
opfmethod> of its containing operator family.
Also, there must be no more than one pg_opclass
row having opcdefault> true for any given combination of
opcmethod> and opcintype>.
pg_operatorpg_operator
The catalog pg_operator> stores information about operators.
See
and for more information.
pg_operator> ColumnsNameTypeReferencesDescriptionoprnamenameName of the operatoroprnamespaceoidpg_namespace.oid
The OID of the namespace that contains this operator
oprowneroidpg_authid.oidOwner of the operatoroprkindcharb> = infix (both), l> = prefix
(left), r> = postfix (right)
oprcanmergeboolThis operator supports merge joinsoprcanhashboolThis operator supports hash joinsoprleftoidpg_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 anyoprcoderegprocpg_proc.oidFunction that implements this operatoroprrestregprocpg_proc.oidRestriction selectivity estimation function for this operatoroprjoinregprocpg_proc.oidJoin selectivity estimation function for this operator
Unused column contain zeroes. For example, oprleft
is zero for a prefix operator.
pg_opfamilypg_opfamily
The catalog pg_opfamily defines operator families.
Each operator family is a collection of operators and associated
support routines that implement the semantics specified for a particular
index access method. Furthermore, the operators in a family are all
compatible>, in a way that is specified by the access method.
The operator family concept allows cross-data-type operators to be used
with indexes and to be reasoned about using knowledge of access method
semantics.
Operator families are described at length in .
pg_opfamily> ColumnsNameTypeReferencesDescriptionopfmethodoidpg_am.oidIndex access method operator family is foropfnamenameName of this operator familyopfnamespaceoidpg_namespace.oidNamespace of this operator familyopfowneroidpg_authid.oidOwner of the operator family
The majority of the information defining an operator family is not in its
pg_opfamily row, but in the associated rows in
pg_amop,
pg_amproc,
and
pg_opclass.
pg_pltemplatepg_pltemplate
The catalog pg_pltemplate stores
template> information for procedural languages.
A template for a language allows the language to be created in a
particular database by a simple CREATE LANGUAGE> command,
with no need to specify implementation details.
Unlike most system catalogs, pg_pltemplate
is shared across all databases of a cluster: there is only one
copy of pg_pltemplate per cluster, not
one per database. This allows the information to be accessible in
each database as it is needed.
pg_pltemplate> ColumnsNameTypeDescriptiontmplnamenameName of the language this template is fortmpltrustedbooleanTrue if language is considered trustedtmpldbacreatebooleanTrue if language may be created by a database ownertmplhandlertextName of call handler functiontmplinlinetextName of anonymous-block handler function, or NULL if nonetmplvalidatortextName of validator function, or NULL if nonetmpllibrarytextPath of shared library that implements languagetmplaclaclitem[]Access privileges for template (not yet used)
There are not currently any commands that manipulate procedural language
templates; to change the built-in information, a superuser must modify
the table using ordinary INSERT, DELETE,
or UPDATE commands. It is likely that a future
release of PostgreSQL will offer
commands to change the entries in a cleaner fashion.
When implemented, the tmplacl field will provide
access control for the template itself (i.e., the right to create a
language using it), not for the languages created from the template.
pg_procpg_proc
The catalog pg_proc> stores information about functions (or procedures).
See
and for more information.
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
proowneroidpg_authid.oidOwner of the functionprolangoidpg_language.oidImplementation language or call interface of this functionprocostfloat4Estimated execution cost (in units of
); if proretset>,
this is cost per row returnedprorowsfloat4Estimated number of result rows (zero if not proretset>)provariadicoidpg_type.oidData type of the variadic array parameter's elements,
or zero if the function does not have a variadic parameterproisaggboolFunction is an aggregate functionproiswindowboolFunction is a window 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 (i.e., 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 might change at any time. (Use v also
for functions with side-effects, so that calls to them cannot get
optimized away.)
pronargsint2Number of input argumentspronargdefaultsint2Number of arguments that have defaultsprorettypeoidpg_type.oidData type of the return valueproargtypesoidvectorpg_type.oid
An array with the data types of the function arguments. This includes
only input arguments (including INOUT and
VARIADIC> arguments), and thus represents
the call signature of the function
proallargtypesoid[]pg_type.oid
An array with the data types of the function arguments. This includes
all arguments (including OUT and
INOUT arguments); however, if all the
arguments are IN arguments, this field will be null.
Note that subscripting is 1-based, whereas for historical reasons
proargtypes> is subscripted from 0
proargmodeschar[]
An array with the modes of the function arguments, encoded as
i for IN> arguments,
o for OUT> arguments,
b for INOUT> arguments,
v for VARIADIC> arguments,
t for TABLE> arguments.
If all the arguments are IN arguments,
this field will be null.
Note that subscripts correspond to positions of
proallargtypes> not proargtypes>
proargnamestext[]
An array with the names of the function arguments.
Arguments without a name are set to empty strings in the array.
If none of the arguments have a name, this field will be null.
Note that subscripts correspond to positions of
proallargtypes> not proargtypes>
proargdefaultstext
Expression trees (in nodeToString() representation)
for default values. This is a list with
pronargdefaults> elements, corresponding to the last
N> input> arguments (i.e., the last
N> proargtypes> positions).
If none of the arguments have defaults, this field will be null
prosrctext
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
probintext
Additional information about how to invoke the function.
Again, the interpretation is language-specific
proconfigtext[]Function's local settings for run-time configuration variablesproaclaclitem[]
Access privileges; see
and
for details
For compiled functions, both built-in and dynamically loaded,
prosrc contains the function's C-language
name (link symbol). For all other currently-known language types,
prosrc contains the function's source
text. probin is unused except for
dynamically-loaded C functions, for which it gives the name of the
shared library file containing the function.
pg_rewritepg_rewrite
The catalog pg_rewrite 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_typechar
Event type that the rule is for: 1 = SELECT>, 2 =
UPDATE>, 3 = INSERT>, 4 =
DELETE>
ev_enabledchar
Controls in which modes
the rule fires.
O> = rule fires in origin> and local> modes,
D> = rule is disabled,
R> = rule fires in replica> mode,
A> = rule fires always.
is_insteadboolTrue if the rule is an INSTEAD ruleev_qualtext
Expression tree (in the form of a
nodeToString() representation) for the
rule's qualifying condition
ev_actiontext
Query 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_db_role_settingpg_db_role_setting
The catalog pg_db_role_setting records the default
values that have been set for run-time configuration variables,
for each role and database combination.
Unlike most system catalogs, pg_db_role_setting
is shared across all databases of a cluster: there is only one
copy of pg_db_role_setting per cluster, not
one per database.
pg_db_role_setting> ColumnsNameTypeReferencesDescriptionsetdatabaseoidpg_database.oidThe OID of the database the setting is applicable to, or zero if not database-specificsetroleoidpg_authid.oidThe OID of the role the setting is applicable to, or zero if not role-specificsetconfigtext[]Defaults for run-time configuration variables
pg_shdependpg_shdepend
The catalog pg_shdepend records the
dependency relationships between database objects and shared objects,
such as roles. This information allows
PostgreSQL to ensure that those objects are
unreferenced before attempting to delete them.
See also pg_depend,
which performs a similar function for dependencies involving objects
within a single database.
Unlike most system catalogs, pg_shdepend
is shared across all databases of a cluster: there is only one
copy of pg_shdepend per cluster, not
one per database.
pg_shdepend> ColumnsNameTypeReferencesDescriptiondbidoidpg_database.oidThe OID of the database the dependent object is in,
or zero for a shared objectclassidoidpg_class.oidThe OID of the system catalog the dependent object is inobjidoidany OID columnThe OID of the specific dependent objectobjsubidint4
For a table column, this is the column number (the
objid> and classid> refer to the
table itself). For all other object types, this column is zero
refclassidoidpg_class.oidThe OID of the system catalog the referenced object is in
(must be a shared catalog)refobjidoidany OID columnThe OID of the specific referenced objectdeptypechar
A code defining the specific semantics of this dependency relationship; see text
In all cases, a pg_shdepend entry indicates that
the referenced object cannot be dropped without also dropping the dependent
object. However, there are several subflavors identified by
deptype>:
SHARED_DEPENDENCY_OWNER> (o>)
The referenced object (which must be a role) is the owner of the
dependent object.
SHARED_DEPENDENCY_ACL> (a>)
The referenced object (which must be a role) is mentioned in the
ACL (access control list, i.e., privileges list) of the
dependent object. (A SHARED_DEPENDENCY_ACL> entry is
not made for the owner of the object, since the owner will have
a SHARED_DEPENDENCY_OWNER> entry anyway.)
SHARED_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 by initdb. The columns for the
dependent object contain zeroes.
Other dependency flavors might be needed in future. Note in particular
that the current definition only supports roles as referenced objects.
pg_shdescriptionpg_shdescription
The catalog pg_shdescription stores optional
descriptions (comments) for shared database objects. Descriptions can be
manipulated with the command and viewed with
psql's \d commands.
See also pg_description,
which performs a similar function for descriptions involving objects
within a single database.
Unlike most system catalogs, pg_shdescription
is shared across all databases of a cluster: there is only one
copy of pg_shdescription per cluster, not
one per database.
pg_shdescription> ColumnsNameTypeReferencesDescriptionobjoidoidany OID columnThe OID of the object this description pertains toclassoidoidpg_class.oidThe OID of the system catalog this object appears indescriptiontextArbitrary text that serves as the description of this object
pg_statisticpg_statistic
The catalog pg_statistic stores
statistical data about the contents of the database. Entries are
created by
and subsequently used by the query planner. Note that all the
statistical data is inherently approximate, even assuming that it
is up-to-date.
Normally there is one entry, with stainherit> =
false>, for each table column that has been analyzed.
If the table has inheritance children, a second entry with
stainherit> = true> is also created. This row
represents the column's statistics over the inheritance tree, i.e.,
statistics for the data you'd see with
SELECT column> FROM table>*,
whereas the stainherit> = false> row represents
the results of
SELECT column> FROM ONLY table>.
pg_statistic also stores statistical data about
the values of index expressions. These are described as if they were
actual data columns; in particular, starelid
references the index. No entry is made for an ordinary non-expression
index column, however, since it would be redundant with the entry
for the underlying table column. Currently, entries for index expressions
always have stainherit> = false>.
Since different kinds of statistics might 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 nullness) 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
might 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_statistic> ColumnsNameTypeReferencesDescriptionstarelidoidpg_class.oidThe table or index that the described column belongs tostaattnumint2pg_attribute.attnumThe number of the described columnstainheritboolIf true, the stats include inheritance child columns, not just the
values in the specified relationstanullfracfloat4The fraction of the column's entries that are nullstawidthint4The average stored width, in bytes, of nonnull entriesstadistinctfloat4The number of distinct nonnull 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 multiplier for 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
stakindN>int2
A code number indicating the kind of statistics stored in the
N>th slot of the
pg_statistic row
staopN>oidpg_operator.oid
An operator used to derive the statistics stored in the
N>th slot. For example, a
histogram slot would show the < operator
that defines the sort order of the data
stanumbersN>float4[]
Numerical statistics of the appropriate kind for the
N>th slot, or NULL if the slot
kind does not involve numerical values
stavaluesN>anyarray
Column data values of the appropriate kind for the
N>th slot, or NULL if the slot
kind does not store any data values. Each array's element
values are actually of the specific column's data type, so there
is no way to define these columns' type more specifically than
anyarray>
pg_tablespacepg_tablespace
The catalog pg_tablespace stores information
about the available tablespaces. Tables can be placed in particular
tablespaces to aid administration of disk layout.
Unlike most system catalogs, pg_tablespace
is shared across all databases of a cluster: there is only one
copy of pg_tablespace per cluster, not
one per database.
pg_tablespace> ColumnsNameTypeReferencesDescriptionspcnamenameTablespace namespcowneroidpg_authid.oidOwner of the tablespace, usually the user who created itspclocationtextLocation (directory path) of the tablespacespcaclaclitem[]
Access privileges; see
and
for details
spcoptionstext[]
Tablespace-level options, as keyword=value> strings
pg_triggerpg_trigger
The catalog pg_trigger stores triggers on tables.
See
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 calledtgtypeint2Bit mask identifying trigger conditionstgenabledchar
Controls in which modes
the trigger fires.
O> = trigger fires in origin> and local> modes,
D> = trigger is disabled,
R> = trigger fires in replica> mode,
A> = trigger fires always.
tgisinternalboolTrue if trigger is internally generated (usually, to enforce
the constraint identified by tgconstraint>)tgconstrrelidoidpg_class.oidThe table referenced by a referential integrity constrainttgconstrindidoidpg_class.oidThe index supporting a unique, primary key, or referential integrity constrainttgconstraintoidpg_constraint.oidThe pg_constraint> entry associated with the trigger, if anytgdeferrableboolTrue if constraint trigger is deferrabletginitdeferredboolTrue if constraint trigger is initially deferredtgnargsint2Number of argument strings passed to trigger functiontgattrint2vectorpg_attribute.attnumcolumn numbers, if trigger is column-specific; otherwise an
empty arraytgargsbyteaArgument strings to pass to trigger, each NULL-terminatedtgqualtextExpression tree (in nodeToString()
representation) for the trigger's WHEN> condition, or NULL
if none
Currently, column-specific triggering is supported only for
UPDATE> events, and so tgattr> is relevant
only for that event type. tgtype might
contain bits for other event types as well, but those are presumed
to be table-wide regardless of what is in tgattr>.
When tgconstraint> is nonzero,
tgconstrrelid>, tgconstrindid>,
tgdeferrable>, and tginitdeferred> are
largely redundant with the referenced pg_constraint> entry.
However, it is possible for a non-deferrable trigger to be associated
with a deferrable constraint: foreign key constraints can have some
deferrable and some non-deferrable triggers.
pg_class.relhastriggers
must be true if a table has any triggers in this catalog.
pg_ts_configpg_ts_config
The pg_ts_config catalog contains entries
representing text search configurations. A configuration specifies
a particular text search parser and a list of dictionaries to use
for each of the parser's output token types. The parser is shown
in the pg_ts_config entry, but the
token-to-dictionary mapping is defined by subsidiary entries in pg_ts_config_map.
PostgreSQL's text search features are
described at length in .
pg_ts_config> ColumnsNameTypeReferencesDescriptioncfgnamenameText search configuration namecfgnamespaceoidpg_namespace.oid
The OID of the namespace that contains this configuration
cfgowneroidpg_authid.oidOwner of the configurationcfgparseroidpg_ts_parser.oidThe OID of the text search parser for this configuration
pg_ts_config_mappg_ts_config_map
The pg_ts_config_map catalog contains entries
showing which text search dictionaries should be consulted, and in
what order, for each output token type of each text search configuration's
parser.
PostgreSQL's text search features are
described at length in .
pg_ts_config_map> ColumnsNameTypeReferencesDescriptionmapcfgoidpg_ts_config.oidThe OID of the pg_ts_config> entry owning this map entrymaptokentypeintegerA token type emitted by the configuration's parsermapseqnointegerOrder in which to consult this entry (lower
mapseqno>s first)mapdictoidpg_ts_dict.oidThe OID of the text search dictionary to consult
pg_ts_dictpg_ts_dict
The pg_ts_dict catalog contains entries
defining text search dictionaries. A dictionary depends on a text
search template, which specifies all the implementation functions
needed; the dictionary itself provides values for the user-settable
parameters supported by the template. This division of labor allows
dictionaries to be created by unprivileged users. The parameters
are specified by a text string dictinitoption>,
whose format and meaning vary depending on the template.
PostgreSQL's text search features are
described at length in .
pg_ts_dict> ColumnsNameTypeReferencesDescriptiondictnamenameText search dictionary namedictnamespaceoidpg_namespace.oid
The OID of the namespace that contains this dictionary
dictowneroidpg_authid.oidOwner of the dictionarydicttemplateoidpg_ts_template.oidThe OID of the text search template for this dictionarydictinitoptiontextInitialization option string for the template
pg_ts_parserpg_ts_parser
The pg_ts_parser catalog contains entries
defining text search parsers. A parser is responsible for splitting
input text into lexemes and assigning a token type to each lexeme.
Since a parser must be implemented by C-language-level functions,
creation of new parsers is restricted to database superusers.
PostgreSQL's text search features are
described at length in .
pg_ts_parser> ColumnsNameTypeReferencesDescriptionprsnamenameText search parser nameprsnamespaceoidpg_namespace.oid
The OID of the namespace that contains this parser
prsstartregprocpg_proc.oidOID of the parser's startup functionprstokenregprocpg_proc.oidOID of the parser's next-token functionprsendregprocpg_proc.oidOID of the parser's shutdown functionprsheadlineregprocpg_proc.oidOID of the parser's headline functionprslextyperegprocpg_proc.oidOID of the parser's lextype function
pg_ts_templatepg_ts_template
The pg_ts_template catalog contains entries
defining text search templates. A template is the implementation
skeleton for a class of text search dictionaries.
Since a template must be implemented by C-language-level functions,
creation of new templates is restricted to database superusers.
PostgreSQL's text search features are
described at length in .
pg_ts_template> ColumnsNameTypeReferencesDescriptiontmplnamenameText search template nametmplnamespaceoidpg_namespace.oid
The OID of the namespace that contains this template
tmplinitregprocpg_proc.oidOID of the template's initialization functiontmpllexizeregprocpg_proc.oidOID of the template's lexize function
pg_typepg_type
The catalog pg_type stores information about data
types. Base types and enum types (scalar types) are created with
, and
domains with
.
A composite type is automatically created for each table in the database, to
represent the row structure of the table. It is also possible to create
composite types with CREATE TYPE AS.
pg_type> ColumnsNameTypeReferencesDescriptiontypnamenameData type nametypnamespaceoidpg_namespace.oid
The OID of the namespace that contains this type
typowneroidpg_authid.oidOwner 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.
typbyval had better be false if
typlen is not 1, 2, or 4 (or 8 on machines
where Datum is 8 bytes).
Variable-length types are always passed by reference. Note that
typbyval can be false even if the
length would allow pass-by-value
typtypechartyptype is
b for a base type,
c for a composite type (e.g., a table's row type),
d for a domain,
e for an enum type,
or p for a pseudo-type.
See also typrelid and
typbasetypetypcategorychartypcategory is an arbitrary classification
of data types that is used by the parser to determine which implicit
casts should be preferred>.
See typispreferredbool
True if the type is a preferred cast target within its
typcategorytypisdefinedbool
True 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
typdelimchar
Character 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 composite type (see
typtype), then this column 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-composite 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 point.
If a fixed-length type has a typelem then
its internal representation must be some number of values of the
typelem data type with no other data.
Variable-length array types have a header defined by the array
subroutines
typarrayoidpg_type.oid
If typarray is not 0 then it
identifies another row in pg_type, which
is the true array type having this type as element
typinputregprocpg_proc.oidInput conversion function (text format)typoutputregprocpg_proc.oidOutput conversion function (text format)typreceiveregprocpg_proc.oidInput conversion function (binary format), or 0 if nonetypsendregprocpg_proc.oidOutput conversion function (binary format), or 0 if nonetypmodinregprocpg_proc.oidType modifier input function, or 0 if type does not support modifierstypmodoutregprocpg_proc.oidType modifier output function, or 0 to use the standard formattypanalyzeregprocpg_proc.oidCustom ANALYZE function, or 0 to use the standard 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 column in
a structure 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 stored in secondary storage.
Note that m> columns can also be moved out to secondary
storage, but only as a last resort (e> and x> columns are
moved first).
typnotnullbooltypnotnull represents a not-null
constraint on a type. Used for domains only
typbasetypeoidpg_type.oid
If this is a domain (see typtype), then
typbasetype identifies the type that this
one is based on. Zero if this type is not a domain
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 types other than domains over array types
typdefaultbintext
If typdefaultbin> is not null, it is the nodeToString()
representation of a default expression for the type. 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 might be fed to the type's input
converter to produce a constant
lists the system-defined values
of typcategory>. Any future additions to this list will
also be upper-case ASCII letters. All other ASCII characters are reserved
for user-defined categories.
pg_user_mappingpg_user_mapping
The catalog pg_user_mapping stores
the mappings from local user to remote. Access to this catalog is
restricted from normal users, use the view
pg_user_mappings
instead.
pg_user_mapping> ColumnsNameTypeReferencesDescriptionumuseroidpg_authid.oidOID of the local role being mapped, 0 if the user mapping is publicumserveroidpg_foreign_server.oid
The OID of the foreign server that contains this mapping
umoptionstext[]
User mapping specific options, as keyword=value> strings.
System Views
In addition to the system catalogs, PostgreSQL
provides a number of built-in views. Some system views provide convenient
access to some commonly used queries on the system catalogs. Other views
provide access to internal server state.
The information schema () provides
an alternative set of views which overlap the functionality of the system
views. Since the information schema is SQL-standard whereas the views
described here are PostgreSQL-specific,
it's usually better to use the information schema if it provides all
the information you need.
lists the system views described here.
More detailed documentation of each view follows below.
There are some additional views that provide access to the results of
the statistics collector; they are described in .
Except where noted, all the views described here are read-only.
System ViewsView NamePurposepg_cursorsopen cursorspg_groupgroups of database userspg_indexesindexespg_lockscurrently held lockspg_prepared_statementsprepared statementspg_prepared_xactsprepared transactionspg_rolesdatabase rolespg_rulesrulespg_settingsparameter settingspg_shadowdatabase userspg_statsplanner statisticspg_tablestablespg_timezone_abbrevstime zone abbreviationspg_timezone_namestime zone namespg_userdatabase userspg_viewsviews
pg_cursorspg_cursors
The pg_cursors view lists the cursors that
are currently available. Cursors can be defined in several ways:
via the
statement in SQL
via the Bind message in the frontend/backend protocol, as
described in
via the Server Programming Interface (SPI), as described in
The pg_cursors view displays cursors
created by any of these means. Cursors only exist for the duration
of the transaction that defines them, unless they have been
declared WITH HOLD. Therefore non-holdable
cursors are only present in the view until the end of their
creating transaction.
Cursors are used internally to implement some of the components
of PostgreSQL>, such as procedural languages.
Therefore, the pg_cursors> view might include cursors
that have not been explicitly created by the user.
pg_cursors> ColumnsNameTypeDescriptionnametextThe name of the cursorstatementtextThe verbatim query string submitted to declare this cursoris_holdablebooleantrue if the cursor is holdable (that is, it
can be accessed after the transaction that declared the cursor
has committed); false otherwise
is_binarybooleantrue if the cursor was declared
BINARY; false
otherwise
is_scrollablebooleantrue> if the cursor is scrollable (that is, it
allows rows to be retrieved in a nonsequential manner);
false otherwise
creation_timetimestamptzThe time at which the cursor was declared
The pg_cursors view is read only.
pg_grouppg_group
The view pg_group exists for backwards
compatibility: it emulates a catalog that existed in
PostgreSQL before version 8.1.
It shows the names and members of all roles that are marked as not
rolcanlogin>, which is an approximation to the set
of roles that are being used as groups.
pg_group> ColumnsNameTypeReferencesDescriptiongronamenamepg_authid.rolnameName of the groupgrosysidoidpg_authid.oidID of this groupgrolistoid[]pg_authid.oidAn array containing the IDs of the roles in this group
pg_indexespg_indexes
The view pg_indexes provides access to
useful information about each index in the database.
pg_indexes> ColumnsNameTypeReferencesDescriptionschemanamenamepg_namespace.nspnameName of schema containing table and indextablenamenamepg_class.relnameName of table the index is forindexnamenamepg_class.relnameName of indextablespacenamepg_tablespace.spcnameName of tablespace containing index (NULL if default for database)indexdeftextIndex definition (a reconstructed CREATE INDEX
command)
pg_lockspg_locks
The view pg_locks provides access to
information about the locks held by open transactions within the
database server. See for more discussion
of locking.
pg_locks contains one row per active lockable
object, requested lock mode, and relevant transaction. Thus, the same
lockable object might
appear many times, if multiple transactions are holding or waiting
for locks on it. However, an object that currently has no locks on it
will not appear at all.
There are several distinct types of lockable objects:
whole relations (e.g., tables), individual pages of relations,
individual tuples of relations,
transaction IDs (both virtual and permanent IDs),
and general database objects (identified by class OID and object OID,
in the same way as in pg_description or
pg_depend). Also, the right to extend a
relation is represented as a separate lockable object.
pg_locks> ColumnsNameTypeReferencesDescriptionlocktypetext
type of the lockable object:
relation>,
extend>,
page>,
tuple>,
transactionid>,
virtualxid>,
object>,
userlock>, or
advisory>
databaseoidpg_database.oid
OID of the database in which the object exists, or
zero if the object is a shared object, or
NULL if the object is a transaction ID
relationoidpg_class.oid
OID of the relation, or NULL if the object is not
a relation or part of a relation
pageinteger
Page number within the relation, or NULL if the object
is not a tuple or relation page
tuplesmallint
Tuple number within the page, or NULL if the object is not a tuple
virtualxidtext
Virtual ID of a transaction, or NULL if the object is not a
virtual transaction ID
transactionidxid
ID of a transaction, or NULL if the object is not a transaction ID
classidoidpg_class.oid
OID of the system catalog containing the object, or NULL if the
object is not a general database object
objidoidany OID column
OID of the object within its system catalog, or NULL if the
object is not a general database object.
For advisory locks it is used to distinguish the two key
spaces (1> for an int8 key, 2> for two
int4 keys).
objsubidsmallint
For a table column, this is the column number (the
classid> and objid> refer to the
table itself). For all other object types, this column is
zero. NULL if the object is not a general database object
virtualtransactiontext
Virtual ID of the transaction that is holding or awaiting this lock
pidinteger
Process ID of the server process holding or awaiting this
lock. NULL if the lock is held by a prepared transaction
modetextName of the lock mode held or desired by this process (see )grantedbooleanTrue if lock is held, false if lock is awaited
granted is true in a row representing a lock
held by the indicated transaction. False indicates that this transaction is
currently waiting to acquire this lock, which implies that some other
transaction is holding a conflicting lock mode on the same lockable object.
The waiting transaction will sleep until the other lock is released (or a
deadlock situation is detected). A single transaction can be waiting to
acquire at most one lock at a time.
Every transaction holds an exclusive lock on its virtual transaction ID for
its entire duration. If a permanent ID is assigned to the transaction
(which normally happens only if the transaction changes the state of the
database), it also holds an exclusive lock on its permanent transaction ID
until it ends. When one transaction finds it necessary to wait specifically
for another transaction, it does so by attempting to acquire share lock on
the other transaction ID (either virtual or permanent ID depending on the
situation). That will succeed only when the other transaction
terminates and releases its locks.
Although tuples are a lockable type of object,
information about row-level locks is stored on disk, not in memory,
and therefore row-level locks normally do not appear in this view.
If a transaction is waiting for a
row-level lock, it will usually appear in the view as waiting for the
permanent transaction ID of the current holder of that row lock.
Advisory locks can be acquired on keys consisting of either a single
bigint value or two integer values. A bigint key is displayed with its
high-order half in the classid> column, its low-order half
in the objid> column, and objsubid> equal
to 1. Integer keys are displayed with the first key in the
classid> column, the second key in the objid>
column, and objsubid> equal to 2. The actual meaning of
the keys is up to the user. Advisory locks are local to each database,
so the database> column is meaningful for an advisory lock.
When the pg_locks view is accessed, the
internal lock manager data structures are momentarily locked, and
a copy is made for the view to display. This ensures that the
view produces a consistent set of results, while not blocking
normal lock manager operations longer than necessary. Nonetheless
there could be some impact on database performance if this view is
frequently accessed.
pg_locks provides a global view of all locks
in the database cluster, not only those relevant to the current database.
Although its relation column can be joined
against pg_class>.oid> to identify locked
relations, this will only work correctly for relations in the current
database (those for which the database column
is either the current database's OID or zero).
The pid column can be joined to the
procpid column of the
pg_stat_activity view to get more
information on the session holding or waiting to hold each lock.
Also, if you are using prepared transactions, the
transaction> column can be joined to the
transaction column of the
pg_prepared_xacts view to get more
information on prepared transactions that hold locks.
(A prepared transaction can never be waiting for a lock,
but it continues to hold the locks it acquired while running.)
pg_prepared_statementspg_prepared_statements
The pg_prepared_statements view displays
all the prepared statements that are available in the current
session. See for more information about prepared
statements.
pg_prepared_statements contains one row
for each prepared statement. Rows are added to the view when a new
prepared statement is created and removed when a prepared statement
is released (for example, via the command).
pg_prepared_statements> ColumnsNameTypeDescriptionnametext
The identifier of the prepared statement
statementtext
The query string submitted by the client to create this
prepared statement. For prepared statements created via SQL,
this is the PREPARE statement submitted by
the client. For prepared statements created via the
frontend/backend protocol, this is the text of the prepared
statement itself
prepare_timetimestamptz
The time at which the prepared statement was created
parameter_typesregtype[]
The expected parameter types for the prepared statement in the
form of an array of regtype. The OID corresponding
to an element of this array can be obtained by casting the
regtype value to oidfrom_sqlbooleantrue if the prepared statement was created
via the PREPARE SQL statement;
false if the statement was prepared via the
frontend/backend protocol
The pg_prepared_statements view is read only.
pg_prepared_xactspg_prepared_xacts
The view pg_prepared_xacts displays
information about transactions that are currently prepared for two-phase
commit (see for details).
pg_prepared_xacts contains one row per prepared
transaction. An entry is removed when the transaction is committed or
rolled back.
pg_prepared_xacts> ColumnsNameTypeReferencesDescriptiontransactionxid
Numeric transaction identifier of the prepared transaction
gidtext
Global transaction identifier that was assigned to the transaction
preparedtimestamp with time zone
Time at which the transaction was prepared for commit
ownernamepg_authid.rolname
Name of the user that executed the transaction
databasenamepg_database.datname
Name of the database in which the transaction was executed
When the pg_prepared_xacts view is accessed, the
internal transaction manager data structures are momentarily locked, and
a copy is made for the view to display. This ensures that the
view produces a consistent set of results, while not blocking
normal operations longer than necessary. Nonetheless
there could be some impact on database performance if this view is
frequently accessed.
pg_rolespg_roles
The view pg_roles provides access to
information about database roles. This is simply a publicly
readable view of
pg_authid
that blanks out the password field.
This view explicitly exposes the OID column of the underlying table,
since that is needed to do joins to other catalogs.
pg_roles> ColumnsNameTypeReferencesDescriptionrolnamenameRole namerolsuperboolRole has superuser privilegesrolinheritboolRole automatically inherits privileges of roles it is a
member ofrolcreateroleboolRole can create more rolesrolcreatedbboolRole can create databasesrolcatupdatebool
Role can update system catalogs directly. (Even a superuser cannot do
this unless this column is true.)
rolcanloginbool
Role can log in. That is, this role can be given as the initial
session authorization identifier
rolconnlimitint4
For roles that can log in, this sets maximum number of concurrent
connections this role can make. -1 means no limit
rolpasswordtextNot the password (always reads as ********>)rolvaliduntiltimestamptzPassword expiry time (only used for password authentication);
NULL if no expirationoidoidpg_authid.oidID of role
pg_rulespg_rules
The view pg_rules provides access to
useful information about query rewrite rules.
pg_rules> ColumnsNameTypeReferencesDescriptionschemanamenamepg_namespace.nspnameName of schema containing tabletablenamenamepg_class.relnameName of table the rule is forrulenamenamepg_rewrite.rulenameName of ruledefinitiontextRule definition (a reconstructed creation command)
The pg_rules> view excludes the ON SELECT> rules
of views; those can be seen in pg_views>.
pg_settingspg_settings
The view pg_settings provides access to
run-time parameters of the server. It is essentially an alternative
interface to the
and commands.
It also provides access to some facts about each parameter that are
not directly available from SHOW>, such as minimum and
maximum values.
pg_settings> ColumnsNameTypeDescriptionnametextRun-time configuration parameter namesettingtextCurrent value of the parameterunittextImplicit unit of the parametercategorytextLogical group of the parametershort_desctextA brief description of the parameterextra_desctextAdditional, more detailed, description of the parametercontexttextContext required to set the parameter's valuevartypetextParameter type (bool>, enum>,
integer>, real>, or string>)
sourcetextSource of the current parameter valuemin_valtextMinimum allowed value of the parameter (NULL for non-numeric
values)max_valtextMaximum allowed value of the parameter (NULL for non-numeric
values)enumvalstext[]Allowed values of an enum parameter (NULL for non-enum
values)boot_valtextParameter value assumed at server startup if the parameter is
not otherwise setreset_valtextValue that RESET would reset the parameter to
in the current sessionsourcefiletextConfiguration file the current value was set in (NULL for
values set from sources other than configuration files, or when
examined by a non-superuser).
Helpful when using configuration include directivessourcelineintegerLine number within the configuration file the current value was
set at (NULL for values set from sources other than configuration files,
or when examined by a non-superuser)
The pg_settings view cannot be inserted into or
deleted from, but it can be updated. An UPDATE applied
to a row of pg_settings is equivalent to executing
the command on that named
parameter. The change only affects the value used by the current
session. If an UPDATE is issued within a transaction
that is later aborted, the effects of the UPDATE command
disappear when the transaction is rolled back. Once the surrounding
transaction is committed, the effects will persist until the end of the
session, unless overridden by another UPDATE or
SET.
pg_shadowpg_shadow
The view pg_shadow exists for backwards
compatibility: it emulates a catalog that existed in
PostgreSQL before version 8.1.
It shows properties of all roles that are marked as
rolcanlogin>.
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.
pg_shadow> ColumnsNameTypeReferencesDescriptionusenamenamepg_authid.rolnameUser nameusesysidoidpg_authid.oidID of this userusecreatedbboolUser can create databasesusesuperboolUser is a superuserusecatupdbool
User can update system catalogs. (Even a superuser cannot do
this unless this column is true.)
passwdtextPassword (possibly encrypted)valuntilabstimePassword expiry time (only used for password authentication)useconfigtext[]Session defaults for run-time configuration variables
pg_statspg_stats
The view pg_stats provides access to
the information stored in the pg_statistic
catalog. This view allows access only to rows of
pg_statistic that correspond to tables the
user has permission to read, and therefore it is safe to allow public
read access to this view.
pg_stats is also designed to present the
information in a more readable format than the underlying catalog
— at the cost that its schema must be extended whenever new slot types
are defined for pg_statistic.
pg_stats> ColumnsNameTypeReferencesDescriptionschemanamenamepg_namespace.nspnameName of schema containing tabletablenamenamepg_class.relnameName of tableattnamenamepg_attribute.attnameName of the column described by this rowinheritedboolIf true, this row includes inheritance child columns, not just the
values in the specified tablenull_fracrealFraction of column entries that are nullavg_widthintegerAverage width in bytes of column's entriesn_distinctreal
If greater than zero, the estimated number of distinct values in the
column. If less than zero, the negative of the number of distinct
values divided by the number of rows. (The negated form is used when
ANALYZE> believes that the number of distinct values is
likely to increase as the table grows; the positive form is used when
the column seems to have a fixed number of possible values.) For
example, -1 indicates a unique column in which the number of distinct
values is the same as the number of rows
most_common_valsanyarray
A list of the most common values in the column. (NULL if
no values seem to be more common than any others.)
For some datatypes such as tsvector>, this is a list of
the most common element values rather than values of the type itself.
most_common_freqsreal[]
A list of the frequencies of the most common values or elements,
i.e., number of occurrences of each divided by total number of rows.
(NULL when most_common_vals is.)
For some datatypes such as tsvector>, it can also store some
additional information, making it longer than the
most_common_vals> array.
histogram_boundsanyarray
A list of values that divide the column's values into groups of
approximately equal population. The values in
most_common_vals>, if present, are omitted from this
histogram calculation. (This column is NULL if the column data type
does not have a <> operator or if the
most_common_vals> list accounts for the entire
population.)
correlationreal
Statistical correlation between physical row ordering and
logical ordering of the column values. This ranges from -1 to +1.
When the value is near -1 or +1, an index scan on the column will
be estimated to be cheaper than when it is near zero, due to reduction
of random access to the disk. (This column is NULL if the column data
type does not have a <> operator.)
The maximum number of entries in the most_common_vals>
and histogram_bounds> arrays can be set on a
column-by-column basis using the ALTER TABLE SET STATISTICS>
command, or globally by setting the
run-time parameter.
pg_tablespg_tables
The view pg_tables provides access to
useful information about each table in the database.
pg_tables> ColumnsNameTypeReferencesDescriptionschemanamenamepg_namespace.nspnameName of schema containing tabletablenamenamepg_class.relnameName of tabletableownernamepg_authid.rolnameName of table's ownertablespacenamepg_tablespace.spcnameName of tablespace containing table (NULL if default for database)hasindexesbooleanpg_class.relhasindextrue if table has (or recently had) any indexeshasrulesbooleanpg_class.relhasrulestrue if table has (or once had) ruleshastriggersbooleanpg_class.relhastriggerstrue if table has (or once had) triggers
pg_timezone_abbrevspg_timezone_abbrevs
The view pg_timezone_abbrevs provides a list
of time zone abbreviations that are currently recognized by the datetime
input routines. The contents of this view change when the
run-time parameter is modified.
pg_timezone_abbrevs> ColumnsNameTypeDescriptionabbrevtextTime zone abbreviationutc_offsetintervalOffset from UTC (positive means east of Greenwich)is_dstbooleanTrue if this is a daylight-savings abbreviation
pg_timezone_namespg_timezone_names
The view pg_timezone_names provides a list
of time zone names that are recognized by SET TIMEZONE>,
along with their associated abbreviations, UTC offsets,
and daylight-savings status.
Unlike the abbreviations shown in pg_timezone_abbrevs, many of these names imply a set of daylight-savings transition
date rules. Therefore, the associated information changes across local DST
boundaries. The displayed information is computed based on the current
value of CURRENT_TIMESTAMP>.
pg_timezone_names> ColumnsNameTypeDescriptionnametextTime zone nameabbrevtextTime zone abbreviationutc_offsetintervalOffset from UTC (positive means east of Greenwich)is_dstbooleanTrue if currently observing daylight savings
pg_userpg_user
The view pg_user provides access to
information about database users. This is simply a publicly
readable view of
pg_shadow
that blanks out the password field.
pg_user> ColumnsNameTypeDescriptionusenamenameUser nameusesysidint4User ID (arbitrary number used to reference this user)usecreatedbboolUser can create databasesusesuperboolUser is a superuserusecatupdbool
User can update system catalogs. (Even a superuser cannot do
this unless this column is true.)
passwdtextNot the password (always reads as ********>)valuntilabstimePassword expiry time (only used for password authentication)useconfigtext[]Session defaults for run-time configuration variables
pg_user_mappingspg_user_mappings
The view pg_user_mappings provides access
to information about user mappings. This is essentially a publicly
readable view of
pg_user_mapping
that leaves out the options field if the user has no rights to use
it.
pg_user_mappings> ColumnsNameTypeReferencesDescriptionumidoidpg_user_mapping.oidOID of the user mappingsrvidoidpg_foreign_server.oid
The OID of the foreign server that contains this mapping
srvnametext
Name of the foreign server
umuseroidpg_authid.oidOID of the local role being mapped, 0 if the user mapping is publicusenamenameName of the local user to be mappedumoptionstext[]
User mapping specific options, as keyword=value>
strings, if the current user is the owner of the foreign
server, else null.
pg_viewspg_views
The view pg_views provides access to
useful information about each view in the database.
pg_views> ColumnsNameTypeReferencesDescriptionschemanamenamepg_namespace.nspnameName of schema containing viewviewnamenamepg_class.relnameName of viewviewownernamepg_authid.rolnameName of view's ownerdefinitiontextView definition (a reconstructed SELECT query)