| 1 |
<!-- |
| 2 |
doc/src/sgml/ref/alter_trigger.sgml |
| 3 |
PostgreSQL documentation |
| 4 |
--> |
| 5 |
|
| 6 |
<refentry id="sql-altertrigger"> |
| 7 |
<indexterm zone="sql-altertrigger"> |
| 8 |
<primary>ALTER TRIGGER</primary> |
| 9 |
</indexterm> |
| 10 |
|
| 11 |
<refmeta> |
| 12 |
<refentrytitle>ALTER TRIGGER</refentrytitle> |
| 13 |
<manvolnum>7</manvolnum> |
| 14 |
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>ALTER TRIGGER</refname> |
| 19 |
<refpurpose>change the definition of a trigger</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<synopsis> |
| 24 |
ALTER TRIGGER <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table_name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable> |
| 25 |
ALTER TRIGGER <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table_name</replaceable> [ NO ] DEPENDS ON EXTENSION <replaceable class="parameter">extension_name</replaceable> |
| 26 |
</synopsis> |
| 27 |
</refsynopsisdiv> |
| 28 |
|
| 29 |
<refsect1> |
| 30 |
<title>Description</title> |
| 31 |
|
| 32 |
<para> |
| 33 |
<command>ALTER TRIGGER</command> changes properties of an existing |
| 34 |
trigger. |
| 35 |
</para> |
| 36 |
|
| 37 |
<para> |
| 38 |
The <literal>RENAME</literal> clause changes the name of |
| 39 |
the given trigger without otherwise changing the trigger |
| 40 |
definition. |
| 41 |
If the table that the trigger is on is a partitioned table, |
| 42 |
then corresponding clone triggers in the partitions are |
| 43 |
renamed too. |
| 44 |
</para> |
| 45 |
|
| 46 |
<para> |
| 47 |
The <literal>DEPENDS ON EXTENSION</literal> clause marks |
| 48 |
the trigger as dependent on an extension, such that if the extension is |
| 49 |
dropped, the trigger will automatically be dropped as well. |
| 50 |
</para> |
| 51 |
|
| 52 |
<para> |
| 53 |
You must own the table on which the trigger acts to be allowed to change its properties. |
| 54 |
</para> |
| 55 |
</refsect1> |
| 56 |
|
| 57 |
<refsect1> |
| 58 |
<title>Parameters</title> |
| 59 |
|
| 60 |
<variablelist> |
| 61 |
<varlistentry> |
| 62 |
<term><replaceable class="parameter">name</replaceable></term> |
| 63 |
<listitem> |
| 64 |
<para> |
| 65 |
The name of an existing trigger to alter. |
| 66 |
</para> |
| 67 |
</listitem> |
| 68 |
</varlistentry> |
| 69 |
|
| 70 |
<varlistentry> |
| 71 |
<term><replaceable class="parameter">table_name</replaceable></term> |
| 72 |
<listitem> |
| 73 |
<para> |
| 74 |
The name of the table on which this trigger acts. |
| 75 |
</para> |
| 76 |
</listitem> |
| 77 |
</varlistentry> |
| 78 |
|
| 79 |
<varlistentry> |
| 80 |
<term><replaceable class="parameter">new_name</replaceable></term> |
| 81 |
<listitem> |
| 82 |
<para> |
| 83 |
The new name for the trigger. |
| 84 |
</para> |
| 85 |
</listitem> |
| 86 |
</varlistentry> |
| 87 |
|
| 88 |
<varlistentry> |
| 89 |
<term><replaceable class="parameter">extension_name</replaceable></term> |
| 90 |
<listitem> |
| 91 |
<para> |
| 92 |
The name of the extension that the trigger is to depend on (or no longer |
| 93 |
dependent on, if <literal>NO</literal> is specified). A trigger |
| 94 |
that's marked as dependent on an extension is automatically dropped when |
| 95 |
the extension is dropped. |
| 96 |
</para> |
| 97 |
</listitem> |
| 98 |
</varlistentry> |
| 99 |
</variablelist> |
| 100 |
</refsect1> |
| 101 |
|
| 102 |
<refsect1> |
| 103 |
<title>Notes</title> |
| 104 |
|
| 105 |
<para> |
| 106 |
The ability to temporarily enable or disable a trigger is provided by |
| 107 |
<link linkend="sql-altertable"><command>ALTER TABLE</command></link>, not by |
| 108 |
<command>ALTER TRIGGER</command>, because <command>ALTER TRIGGER</command> has no |
| 109 |
convenient way to express the option of enabling or disabling all of |
| 110 |
a table's triggers at once. |
| 111 |
</para> |
| 112 |
</refsect1> |
| 113 |
|
| 114 |
<refsect1> |
| 115 |
<title>Examples</title> |
| 116 |
|
| 117 |
<para> |
| 118 |
To rename an existing trigger: |
| 119 |
<programlisting> |
| 120 |
ALTER TRIGGER emp_stamp ON emp RENAME TO emp_track_chgs; |
| 121 |
</programlisting></para> |
| 122 |
|
| 123 |
<para> |
| 124 |
To mark a trigger as being dependent on an extension: |
| 125 |
<programlisting> |
| 126 |
ALTER TRIGGER emp_stamp ON emp DEPENDS ON EXTENSION emplib; |
| 127 |
</programlisting></para> |
| 128 |
</refsect1> |
| 129 |
|
| 130 |
<refsect1> |
| 131 |
<title>Compatibility</title> |
| 132 |
|
| 133 |
<para> |
| 134 |
<command>ALTER TRIGGER</command> is a <productname>PostgreSQL</productname> |
| 135 |
extension of the SQL standard. |
| 136 |
</para> |
| 137 |
</refsect1> |
| 138 |
|
| 139 |
<refsect1> |
| 140 |
<title>See Also</title> |
| 141 |
|
| 142 |
<simplelist type="inline"> |
| 143 |
<member><xref linkend="sql-altertable"/></member> |
| 144 |
</simplelist> |
| 145 |
</refsect1> |
| 146 |
</refentry> |