# 51.56. pg\_trigger

The catalog `pg_trigger` stores triggers on tables and views. See [CREATE TRIGGER](https://www.postgresql.org/docs/10/static/sql-createtrigger.html) for more information.

**Table 51.56. `pg_trigger` Columns**

| Name             | Type           | References                                                                                   | Description                                                                                                                                                                                                                                                                                                                 |
| ---------------- | -------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `oid`            | `oid`          |                                                                                              | Row identifier (hidden attribute; must be explicitly selected)                                                                                                                                                                                                                                                              |
| `tgrelid`        | `oid`          | [`pg_class`](https://www.postgresql.org/docs/10/static/catalog-pg-class.html).oid            | The table this trigger is on                                                                                                                                                                                                                                                                                                |
| `tgname`         | `name`         |                                                                                              | Trigger name (must be unique among triggers of same table)                                                                                                                                                                                                                                                                  |
| `tgfoid`         | `oid`          | [`pg_proc`](https://www.postgresql.org/docs/10/static/catalog-pg-proc.html).oid              | The function to be called                                                                                                                                                                                                                                                                                                   |
| `tgtype`         | `int2`         |                                                                                              | Bit mask identifying trigger firing conditions                                                                                                                                                                                                                                                                              |
| `tgenabled`      | `char`         |                                                                                              | Controls in which [session\_replication\_role](https://www.postgresql.org/docs/10/static/runtime-config-client.html#GUC-SESSION-REPLICATION-ROLE) 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. |
| `tgisinternal`   | `bool`         |                                                                                              | True if trigger is internally generated (usually, to enforce the constraint identified by `tgconstraint`)                                                                                                                                                                                                                   |
| `tgconstrrelid`  | `oid`          | [`pg_class`](https://www.postgresql.org/docs/10/static/catalog-pg-class.html).oid            | The table referenced by a referential integrity constraint                                                                                                                                                                                                                                                                  |
| `tgconstrindid`  | `oid`          | [`pg_class`](https://www.postgresql.org/docs/10/static/catalog-pg-class.html).oid            | The index supporting a unique, primary key, referential integrity, or exclusion constraint                                                                                                                                                                                                                                  |
| `tgconstraint`   | `oid`          | [`pg_constraint`](https://www.postgresql.org/docs/10/static/catalog-pg-constraint.html).oid  | The `pg_constraint` entry associated with the trigger, if any                                                                                                                                                                                                                                                               |
| `tgdeferrable`   | `bool`         |                                                                                              | True if constraint trigger is deferrable                                                                                                                                                                                                                                                                                    |
| `tginitdeferred` | `bool`         |                                                                                              | True if constraint trigger is initially deferred                                                                                                                                                                                                                                                                            |
| `tgnargs`        | `int2`         |                                                                                              | Number of argument strings passed to trigger function                                                                                                                                                                                                                                                                       |
| `tgattr`         | `int2vector`   | [`pg_attribute`](https://www.postgresql.org/docs/10/static/catalog-pg-attribute.html).attnum | Column numbers, if trigger is column-specific; otherwise an empty array                                                                                                                                                                                                                                                     |
| `tgargs`         | `bytea`        |                                                                                              | Argument strings to pass to trigger, each NULL-terminated                                                                                                                                                                                                                                                                   |
| `tgqual`         | `pg_node_tree` |                                                                                              | Expression tree (in `nodeToString()` representation) for the trigger's `WHEN` condition, or null if none                                                                                                                                                                                                                    |
| `tgoldtable`     | `name`         |                                                                                              | `REFERENCING` clause name for `OLD TABLE`, or null if none                                                                                                                                                                                                                                                                  |
| `tgnewtable`     | `name`         |                                                                                              | `REFERENCING` clause name for `NEW TABLE`, 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`.

## Note

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.

## Note

`pg_class.relhastriggers` must be true if a relation has any triggers in this catalog.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.postgresql.tw/internals/system-catalogs/51.56.-pg_trigger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
