mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Update compatibility information.
This commit is contained in:
parent
698a5d50c5
commit
a6496a2338
@ -1,9 +1,13 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_trigger.sgml,v 1.16 2001/09/13 15:55:24 petere Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_trigger.sgml,v 1.17 2001/09/13 18:17:44 petere Exp $
|
||||||
Postgres documentation
|
Postgres documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<refentry id="SQL-CREATETRIGGER">
|
<refentry id="SQL-CREATETRIGGER">
|
||||||
|
<docinfo>
|
||||||
|
<date>2001-09-13</date>
|
||||||
|
</docinfo>
|
||||||
|
|
||||||
<refmeta>
|
<refmeta>
|
||||||
<refentrytitle id="SQL-CREATETRIGGER-TITLE">CREATE TRIGGER</refentrytitle>
|
<refentrytitle id="SQL-CREATETRIGGER-TITLE">CREATE TRIGGER</refentrytitle>
|
||||||
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
||||||
@ -134,78 +138,55 @@ CREATE
|
|||||||
<citetitle>PostgreSQL Programmer's Guide</citetitle> for more
|
<citetitle>PostgreSQL Programmer's Guide</citetitle> for more
|
||||||
information.
|
information.
|
||||||
</para>
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect2 id="R2-SQL-CREATETRIGGER-3">
|
<refsect1 id="SQL-CREATETRIGGER-notes">
|
||||||
<refsect2info>
|
<title>Notes</title>
|
||||||
<date>1998-09-21</date>
|
|
||||||
</refsect2info>
|
<para>
|
||||||
<title>
|
To create a trigger on a table, the user must have the
|
||||||
Notes
|
<literal>TRIGGER</literal> privilege on the table.
|
||||||
</title>
|
</para>
|
||||||
<para>
|
|
||||||
<command>CREATE TRIGGER</command> is a <productname>Postgres</productname>
|
<para>
|
||||||
language extension.
|
As of the current release, <literal>STATEMENT</literal> triggers are not implemented.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
|
||||||
Only the relation owner may create a trigger on this relation.
|
<para>
|
||||||
</para>
|
Refer to the <xref linkend="sql-droptrigger"> command for
|
||||||
<para>
|
information on how to remove triggers.
|
||||||
As of the current release, STATEMENT triggers are not implemented.
|
</para>
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
Refer to <command>DROP TRIGGER</command> for information on how to
|
|
||||||
remove triggers.
|
|
||||||
</para>
|
|
||||||
</refsect2>
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1 id="R1-SQL-CREATETRIGGER-2">
|
<refsect1 id="R1-SQL-CREATETRIGGER-2">
|
||||||
<title>
|
<title>Examples</title>
|
||||||
Usage
|
|
||||||
</title>
|
|
||||||
<para>
|
<para>
|
||||||
Check if the specified distributor code exists in the distributors
|
Check if the specified distributor code exists in the distributors
|
||||||
table before appending or updating a row in the table films:
|
table before appending or updating a row in the table films:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE TRIGGER if_dist_exists
|
CREATE TRIGGER if_dist_exists
|
||||||
BEFORE INSERT OR UPDATE ON films FOR EACH ROW
|
BEFORE INSERT OR UPDATE ON films FOR EACH ROW
|
||||||
EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
|
EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Before cancelling a distributor or updating its code, remove every
|
Before cancelling a distributor or updating its code, remove every
|
||||||
reference to the table films:
|
reference to the table films:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE TRIGGER if_film_exists
|
CREATE TRIGGER if_film_exists
|
||||||
BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
|
BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
|
||||||
EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
|
EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1 id="R1-SQL-CREATETRIGGER-3">
|
<para>
|
||||||
<title>
|
The second example can also be done by using a foreign key,
|
||||||
Compatibility
|
constraint as in:
|
||||||
</title>
|
|
||||||
|
|
||||||
<refsect2 id="R2-SQL-CREATETRIGGER-4">
|
|
||||||
<refsect2info>
|
|
||||||
<date>1998-09-21</date>
|
|
||||||
</refsect2info>
|
|
||||||
<title>
|
|
||||||
SQL92
|
|
||||||
</title>
|
|
||||||
|
|
||||||
<para>
|
<programlisting>
|
||||||
There is no <command>CREATE TRIGGER</command> in <acronym>SQL92</acronym>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The second example above may also be done by using a FOREIGN KEY
|
|
||||||
constraint as in:
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
CREATE TABLE distributors (
|
CREATE TABLE distributors (
|
||||||
did DECIMAL(3),
|
did DECIMAL(3),
|
||||||
name VARCHAR(40),
|
name VARCHAR(40),
|
||||||
@ -213,9 +194,84 @@ CREATE TABLE distributors (
|
|||||||
FOREIGN KEY(did) REFERENCES films
|
FOREIGN KEY(did) REFERENCES films
|
||||||
ON UPDATE CASCADE ON DELETE CASCADE
|
ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</refsect2>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 id="SQL-CREATETRIGGER-compatibility">
|
||||||
|
<title>Compatibility</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>SQL92</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
There is no <command>CREATE TRIGGER</command> statement in <acronym>SQL92</acronym>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>SQL99</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <command>CREATE TRIGGER</command> statement in
|
||||||
|
<productname>PostgreSQL</productname> implements a subset of the
|
||||||
|
SQL99 standard. The following functionality is missing:
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
SQL99 allows triggers to fire on updates to specific columns
|
||||||
|
(e.g., <literal>AFTER UPDATE OF col1, col2</literal>).
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
SQL99 allows you to define aliases for the <quote>old</quote>
|
||||||
|
and <quote>new</quote> rows or tables for use in the definiton
|
||||||
|
of the triggered action (e.g., <literal>CREATE TRIGGER ... ON
|
||||||
|
tablename REFERENCING OLD ROW AS somename NEW ROW AS
|
||||||
|
othername ...</literal>). Since
|
||||||
|
<productname>PostgreSQL</productname> allows trigger
|
||||||
|
procedures to be written in any number of user-defined
|
||||||
|
languages, access to the data is handled in a
|
||||||
|
language-specific way.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<productname>PostgreSQL</productname> only has row-level
|
||||||
|
triggers, no statement-level triggers.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<productname>PostgreSQL</productname> only allows the
|
||||||
|
execution of a stored procedure for the triggered action.
|
||||||
|
SQL99 allows the execution of a number of other SQL commands,
|
||||||
|
such as <command>CREATE TABLE</command> as triggered action.
|
||||||
|
This limitation is not hard to work around by creating a
|
||||||
|
stored procedure that executes these commands.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>See Also</title>
|
||||||
|
|
||||||
|
<simplelist type="inline">
|
||||||
|
<member><xref linkend="sql-createfunction"></member>
|
||||||
|
<member><xref linkend="sql-droptrigger"></member>
|
||||||
|
<member><citetitle>PostgreSQL Programmer's Guide</citetitle></member>
|
||||||
|
</simplelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_trigger.sgml,v 1.7 2001/09/03 12:57:50 petere Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_trigger.sgml,v 1.8 2001/09/13 18:17:44 petere Exp $
|
||||||
Postgres documentation
|
Postgres documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<refentry id="SQL-DROPTRIGGER">
|
<refentry id="SQL-DROPTRIGGER">
|
||||||
|
<docinfo>
|
||||||
|
<date>2001-09-13</date>
|
||||||
|
</docinfo>
|
||||||
|
|
||||||
<refmeta>
|
<refmeta>
|
||||||
<refentrytitle id="SQL-DROPTRIGGER-TITLE">
|
<refentrytitle id="SQL-DROPTRIGGER-TITLE">
|
||||||
DROP TRIGGER
|
DROP TRIGGER
|
||||||
@ -101,58 +105,58 @@ ERROR: DropTrigger: there is no trigger <replaceable class="PARAMETER">name</rep
|
|||||||
<para>
|
<para>
|
||||||
<command>DROP TRIGGER</command> will remove all references to an existing
|
<command>DROP TRIGGER</command> will remove all references to an existing
|
||||||
trigger definition. To execute this command the current
|
trigger definition. To execute this command the current
|
||||||
user must be the owner of the trigger.
|
user must be the owner of the table for which the trigger is defined.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<refsect2 id="R2-SQL-DROPTRIGGER-3">
|
|
||||||
<refsect2info>
|
|
||||||
<date>1998-09-22</date>
|
|
||||||
</refsect2info>
|
|
||||||
<title>
|
|
||||||
Notes
|
|
||||||
</title>
|
|
||||||
<para>
|
|
||||||
<command>DROP TRIGGER</command> is a <productname>Postgres</productname>
|
|
||||||
language extension.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
Refer to <command>CREATE TRIGGER</command> for
|
|
||||||
information on how to create triggers.
|
|
||||||
</para>
|
|
||||||
</refsect2>
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1 id="R1-SQL-DROPTRIGGER-2">
|
<refsect1 id="SQL-DROPTRIGGER-examples">
|
||||||
<title>
|
<title>Examples</title>
|
||||||
Usage
|
|
||||||
</title>
|
|
||||||
<para>
|
<para>
|
||||||
Destroy the <literal>if_dist_exists</literal> trigger
|
Destroy the <literal>if_dist_exists</literal> trigger
|
||||||
on table <literal>films</literal>:
|
on table <literal>films</literal>:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
DROP TRIGGER if_dist_exists ON films;
|
DROP TRIGGER if_dist_exists ON films;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1 id="R1-SQL-DROPTRIGGER-3">
|
<refsect1 id="SQL-DROPTRIGGER-compatibility">
|
||||||
<title>
|
<title>Compatibility</title>
|
||||||
Compatibility
|
|
||||||
</title>
|
|
||||||
|
|
||||||
<refsect2 id="R2-SQL-DROPTRIGGER-4">
|
<variablelist>
|
||||||
<refsect2info>
|
<varlistentry>
|
||||||
<date>1998-09-22</date>
|
<term>SQL92</term>
|
||||||
</refsect2info>
|
<listitem>
|
||||||
<title>
|
<para>
|
||||||
SQL92
|
There is no <command>DROP TRIGGER</command> statement in
|
||||||
</title>
|
<acronym>SQL92</acronym>.
|
||||||
<para>
|
</para>
|
||||||
There is no <command>DROP TRIGGER</command> statement in
|
</listitem>
|
||||||
<acronym>SQL92</acronym>.
|
</varlistentry>
|
||||||
</para>
|
|
||||||
</refsect2>
|
<varlistentry>
|
||||||
|
<term>SQL99</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <command>DROP TRIGGER</command> statement in
|
||||||
|
<productname>PostgreSQL</productname> is incompatible with
|
||||||
|
SQL99. In SQL99, trigger names are not local to tables, so the
|
||||||
|
command is simply <literal>DROP TRIGGER
|
||||||
|
<replaceable>name</replaceable></literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>See Also</title>
|
||||||
|
|
||||||
|
<simplelist type="inline">
|
||||||
|
<member><xref linkend="sql-createtrigger"></member>
|
||||||
|
</simplelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user