pg_get_catalog_foreign_keys()

A function listing system catalog foreign keys

pg_get_catalog_foreign_keys() is a system function returning a list of the system catalog pseudo-foreign key relationships.

pg_get_catalog_foreign_keys() was added in PostgreSQL 14.

Usage

pg_get_catalog_foreign_keys () →
          setof record ( fktable regclass,
                         fkcols text[],
                         pktable regclass,
                         pkcols text[],
                         is_array boolean,
                         is_opt boolean )

Change history

Examples

Sample of pg_get_catalog_foreign_keys() content:

postgres=# SELECT *
             FROM pg_get_catalog_foreign_keys()
            WHERE fktable = 'pg_class'::regclass;
 fktable  |     fkcols      |    pktable    | pkcols | is_array | is_opt 
----------+-----------------+---------------+--------+----------+--------
 pg_class | {relnamespace}  | pg_namespace  | {oid}  | f        | f
 pg_class | {reltype}       | pg_type       | {oid}  | f        | t
 pg_class | {reloftype}     | pg_type       | {oid}  | f        | t
 pg_class | {relowner}      | pg_authid     | {oid}  | f        | f
 pg_class | {relam}         | pg_am         | {oid}  | f        | t
 pg_class | {reltablespace} | pg_tablespace | {oid}  | f        | t
 pg_class | {reltoastrelid} | pg_class      | {oid}  | f        | t
 pg_class | {relrewrite}    | pg_class      | {oid}  | f        | t
(8 rows)

Categories

System catalogue, System function