pg_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.
Table 51.18. pg_depend
Columns
Column Type Description |
---|
The OID of the system catalog the dependent object is in |
The OID of the specific dependent object |
For a table column, this is the column number (the |
The OID of the system catalog the referenced object is in |
The OID of the specific referenced object |
For a table column, this is the column number (the |
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 auto-dependent on the table, so that it will go away if the table is dropped.
DEPENDENCY_INTERNAL
(i
)The dependent object was created as part of creation of the referenced object, and is really just a part of its internal implementation. A direct 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 result in automatically dropping the dependent object whether CASCADE
is specified or not. If the dependent object has to be dropped due to a dependency on some other object being removed, its drop is converted to a drop of the referenced object, so that NORMAL
and AUTO
dependencies of the dependent object behave much like they were dependencies of the referenced object. Example: a view's ON SELECT
rule is made internally dependent on the view, preventing it from being dropped while the view remains. Dependencies of the rule (such as tables it refers to) act as if they were dependencies of the view.