Supported Versions: Current (16) / 15 / 14 / 13 / 12
Development Versions: devel
Unsupported versions: 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

3.13. pg_depend

The pg_depend table records the dependency relationships between database objects. This information allows DROP commands to find which other objects must be dropped by DROP CASCADE, or prevent dropping in the DROP RESTRICT case.

Table 3-13. pg_depend Columns

Name Type References Description
classid oid pg_class.oid The oid of the system catalog the dependent object is in
objid oid any oid attribute The oid of the specific dependent object
objsubid int4   For a table attribute, this is the attribute's column number (the objid and classid refer to the table itself). For all other object types, this field is presently zero.
refclassid oid pg_class.oid The oid of the system catalog the referenced object is in
refobjid oid any oid attribute The oid of the specific referenced object
refobjsubid int4   For a table attribute, this is the attribute's column number (the refobjid and refclassid refer to the table itself). For all other object types, this field is presently zero.
deptype char   A code defining the specific semantics of this dependency relationship.

In all cases, a pg_depend entry indicates that the referenced object may not be dropped without also dropping the dependent object. However, there are several subflavors identified by deptype:

  • DEPENDENCY_NORMAL ('n'): normal relationship between separately-created objects. The dependent object may be dropped without affecting the referenced object. The referenced object may only be dropped by specifying CASCADE, in which case the dependent object is dropped too. Example: a table column has a normal dependency on its datatype.

  • DEPENDENCY_AUTO ('a'): the dependent object can be dropped separately from the referenced object, and should be automatically dropped (regardless of RESTRICT or CASCADE mode) if the referenced object is dropped. Example: a named constraint on a table is made auto-dependent on the table, so that it will go away if the table is dropped.

  • DEPENDENCY_INTERNAL ('i'): the dependent object was created as part of creation of the referenced object, and is really just a part of its internal implementation. A DROP of the dependent object will be disallowed outright (we'll tell the user to issue a DROP against the referenced object, instead). A DROP of the referenced object will be propagated through to drop the dependent object whether CASCADE is specified or not. Example: a trigger that's created to enforce a foreign-key constraint is made internally dependent on the constraint's pg_constraint entry.

  • DEPENDENCY_PIN ('p'): there is no dependent object; this type of entry is a signal that the system itself depends on the referenced object, and so that object must never be deleted. Entries of this type are created only during initdb. The fields for the dependent object contain zeroes.

Other dependency flavors may be needed in future.