Summary
The catalog pg_rewrite stores rewrite rules for tables and views.
(Description quoted from the official PostgreSQL documentation.)
Columns
The pg_rewrite system catalog exposes the following columns (names, types and descriptions are taken verbatim from the PostgreSQL documentation):
oidoid
Row identifierrulenamename
Rule nameev_classoidreferencespg_class.oid
The table this rule is forev_typechar
Event type that the rule is for: 1 = select, 2 = update, 3 = insert, 4 = deleteev_enabledchar
Controls in which session_replication_role 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_insteadbool
True if the rule is an INSTEAD ruleev_qualpg_node_tree
Expression tree (in the form of a nodeToString() representation) for the rule’s qualifying conditionev_actionpg_node_tree
Query tree (in the form of a nodeToString() representation) for the rule’s action
Related catalogs
This object references the following other system catalogs:
ev_class→pg_class
Version applicability
Present in PostgreSQL 17, 18, 19 (verified against each release’s documentation). This is a long-standing system object that also exists in earlier PostgreSQL releases.
Related & references
Reference: PostgreSQL documentation — pg_rewrite.