バージョンごとのドキュメント一覧

37.57. triggers #

The view <literal>triggers</literal> contains all triggers defined in the current database on tables and views that the current user owns or has some privilege other than <literal>SELECT</literal> on. triggersビューには、現在のデータベース内で、現在のユーザが所有するあるいは何らかのSELECT以外の権限を持つテーブルまたはビューに定義された、全てのトリガがあります。

表37.55 triggersの列

<title><structname>triggers</structname> Columns</title>

Column Type 列 型

Description 説明

trigger_catalog sql_identifier

Name of the database that contains the trigger (always the current database) トリガを持つデータベースの名前です(常に現在のデータベースです)。

trigger_schema sql_identifier

Name of the schema that contains the trigger トリガを持つスキーマの名前です。

trigger_name sql_identifier

Name of the trigger トリガの名前です。

event_manipulation character_data

Event that fires the trigger (<literal>INSERT</literal>, <literal>UPDATE</literal>, or <literal>DELETE</literal>) トリガを発するイベントです (INSERTUPDATEもしくはDELETEです)。

event_object_catalog sql_identifier

Name of the database that contains the table that the trigger is defined on (always the current database) トリガが定義されたテーブルを持つデータベースの名前です(常に現在のデータベースです)。

event_object_schema sql_identifier

Name of the schema that contains the table that the trigger is defined on トリガが定義されたテーブルを持つスキーマの名前です。

event_object_table sql_identifier

Name of the table that the trigger is defined on トリガが定義されたテーブルの名前です。

action_order cardinal_number

Firing order among triggers on the same table having the same <literal>event_manipulation</literal>, <literal>action_timing</literal>, and <literal>action_orientation</literal>. In <productname>PostgreSQL</productname>, triggers are fired in name order, so this column reflects that. 同じテーブルで同じevent_manipulationaction_timingaction_orientationのトリガを発行する順序です。 PostgreSQLでは、トリガは名前順に発行されますので、この列はそれを反映しています。

action_condition character_data

<literal>WHEN</literal> condition of the trigger, null if none (also null if the table is not owned by a currently enabled role) トリガのWHEN条件です。なければNULLです (現在有効なロールが所有していないテーブルの場合もNULLです)。

action_statement character_data

Statement that is executed by the trigger (currently always <literal>EXECUTE FUNCTION <replaceable>function</replaceable>(...)</literal>) トリガによって実行される文です (現在は常にEXECUTE FUNCTION function(...)です)。

action_orientation character_data

Identifies whether the trigger fires once for each processed row or once for each statement (<literal>ROW</literal> or <literal>STATEMENT</literal>) トリガの発行が処理行ごとか文ごとかを識別します (ROWもしくはSTATEMENTです)。

action_timing character_data

Time at which the trigger fires (<literal>BEFORE</literal>, <literal>AFTER</literal>, or <literal>INSTEAD OF</literal>) トリガを発する時期です (BEFOREAFTERもしくはINSTEAD OFです)。

action_reference_old_table sql_identifier

Name of the <quote>old</quote> transition table, or null if none old遷移テーブルの名前です。なければNULLです。

action_reference_new_table sql_identifier

Name of the <quote>new</quote> transition table, or null if none new遷移テーブルの名前です。なければNULLです。

action_reference_old_row sql_identifier

Applies to a feature not available in <productname>PostgreSQL</productname> PostgreSQLでは利用できない機能に適用されるものです。

action_reference_new_row sql_identifier

Applies to a feature not available in <productname>PostgreSQL</productname> PostgreSQLでは利用できない機能に適用されるものです。

created time_stamp

Applies to a feature not available in <productname>PostgreSQL</productname> PostgreSQLでは利用できない機能に適用されるものです。


Triggers in <productname>PostgreSQL</productname> have two incompatibilities with the SQL standard that affect the representation in the information schema. First, trigger names are local to each table in <productname>PostgreSQL</productname>, rather than being independent schema objects. Therefore there can be duplicate trigger names defined in one schema, so long as they belong to different tables. (<literal>trigger_catalog</literal> and <literal>trigger_schema</literal> are really the values pertaining to the table that the trigger is defined on.) Second, triggers can be defined to fire on multiple events in <productname>PostgreSQL</productname> (e.g., <literal>ON INSERT OR UPDATE</literal>), whereas the SQL standard only allows one. If a trigger is defined to fire on multiple events, it is represented as multiple rows in the information schema, one for each type of event. As a consequence of these two issues, the primary key of the view <literal>triggers</literal> is really <literal>(trigger_catalog, trigger_schema, event_object_table, trigger_name, event_manipulation)</literal> instead of <literal>(trigger_catalog, trigger_schema, trigger_name)</literal>, which is what the SQL standard specifies. Nonetheless, if you define your triggers in a manner that conforms with the SQL standard (trigger names unique in the schema and only one event type per trigger), this will not affect you. PostgreSQLにおけるトリガには、標準SQLと比べ、2つの非互換があり、これらは情報スキーマの表現に影響を与えます。 1つ目は、PostgreSQLではトリガ名は、独立したスキーマオブジェクトではなく、それぞれのテーブル内で局所的であることです。 そのため、別のテーブルに属している場合、1つのスキーマ内でトリガ名を重複させることができます。 (trigger_catalogtrigger_schemaは実際、そのトリガが定義されたテーブルに属する値となります。) 2つ目は、PostgreSQLではトリガは複数のイベントで発行できる点です(例えばON INSERT OR UPDATEです)。 一方、標準SQLでは1つのみしか許されません。 トリガが複数のイベントで発行するように定義された場合、それぞれのイベントで1行という形で、情報スキーマ内では複数の行として表現されます。 これらの2つの問題の結果、triggersビューの主キーは実際、標準SQLで定義された(trigger_catalog, trigger_schema, trigger_name)ではなく、(trigger_catalog, trigger_schema, event_object_table, trigger_name, event_manipulation)となります。 それでもなお、標準SQLに従う(スキーマ内でトリガ名を一意とし、トリガに対し1種類のイベントしか持たせないという)手法でトリガを定義していれば、これは影響ありません。

注記

Prior to <productname>PostgreSQL</productname> 9.1, this view's columns <structfield>action_timing</structfield>, <structfield>action_reference_old_table</structfield>, <structfield>action_reference_new_table</structfield>, <structfield>action_reference_old_row</structfield>, and <structfield>action_reference_new_row</structfield> were named <structfield>condition_timing</structfield>, <structfield>condition_reference_old_table</structfield>, <structfield>condition_reference_new_table</structfield>, <structfield>condition_reference_old_row</structfield>, and <structfield>condition_reference_new_row</structfield> respectively. That was how they were named in the SQL:1999 standard. The new naming conforms to SQL:2003 and later. PostgreSQL 9.1 より前は、このビューの列の action_timingaction_reference_old_tableaction_reference_new_tableaction_reference_old_rowaction_reference_new_row はそれぞれ condition_timingcondition_reference_old_tablecondition_reference_new_tablecondition_reference_old_rowcondition_reference_new_row という名前でした。これらの命名は SQL: 1999標準におけるものです。新しい名前はSQL:2003以降に準拠しています。