↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQL Commands

ALTER TRIGGER

change the definition of a trigger

English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

anchor
SQL-ALTERTRIGGER
file
sql-altertrigger.html
lang
en
name
ALTER TRIGGER
purpose
change the definition of a trigger
purpose zh
更改触发器的定义
sections same as
Unknown
slug
18
synopsis text
ALTER TRIGGER name ON table_name RENAME TO new_name ALTER TRIGGER name ON table_name [ NO ] DEPENDS ON EXTENSION extension_name

Syntax

ALTER TRIGGER name ON table_name RENAME TO new_name
ALTER TRIGGER name ON table_name [ NO ] DEPENDS ON EXTENSION extension_name
Syntax diagrams

Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.

ALTER TRIGGER name ON table_name RENAME TO new_name
ALTER TRIGGER · Syntax 2
ALTER TRIGGER name ON table_name NO DEPENDS ON EXTENSION extension_name

Definition PG 18

ALTER TRIGGER name ON table_name RENAME TO new_name
ALTER TRIGGER name ON table_name [ NO ] DEPENDS ON EXTENSION extension_name

Description

ALTER TRIGGER changes properties of an existing trigger.

The RENAME clause changes the name of the given trigger without otherwise changing the trigger definition. If the table that the trigger is on is a partitioned table, then corresponding clone triggers in the partitions are renamed too.

The DEPENDS ON EXTENSION clause marks the trigger as dependent on an extension, such that if the extension is dropped, the trigger will automatically be dropped as well.

You must own the table on which the trigger acts to be allowed to change its properties.

Parameters

name

The name of an existing trigger to alter.

table_name

The name of the table on which this trigger acts.

new_name

The new name for the trigger.

extension_name

The name of the extension that the trigger is to depend on (or no longer dependent on, if NO is specified). A trigger that's marked as dependent on an extension is automatically dropped when the extension is dropped.

Notes

The ability to temporarily enable or disable a trigger is provided by ALTER TABLE, not by ALTER TRIGGER, because ALTER TRIGGER has no convenient way to express the option of enabling or disabling all of a table's triggers at once.

Examples

To rename an existing trigger:

ALTER TRIGGER emp_stamp ON emp RENAME TO emp_track_chgs;

To mark a trigger as being dependent on an extension:

ALTER TRIGGER emp_stamp ON emp DEPENDS ON EXTENSION emplib;

Compatibility

ALTER TRIGGER is a PostgreSQL extension of the SQL standard.

See Also

ALTER TABLE

Compare versions

Complete source facts

synopsis html

ALTER TRIGGER <em class="replaceable"><code>name</code></em> ON <em class="replaceable"><code>table_name</code></em> RENAME TO <em class="replaceable"><code>new_name</code></em>
ALTER TRIGGER <em class="replaceable"><code>name</code></em> ON <em class="replaceable"><code>table_name</code></em> [ NO ] DEPENDS ON EXTENSION <em class="replaceable"><code>extension_name</code></em>

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · wiki-repair-20261023:f88544372b12dcc3fa6f653c441c93c803d1b4a2221227f803f207f54aaa83bb

Text language: en · wiki-repair-20261023:f88544372b12dcc3fa6f653c441c93c803d1b4a2221227f803f207f54aaa83bb