No big deal; fixed lots of other markup at the same time.
Bigest change: make sure there is no whitespace
in front of <term> contents.
This will probably help the other output types too.
-<REFENTRY ID="SQL-ABORT">
-<REFMETA>
-<REFENTRYTITLE>
-ABORT
-</REFENTRYTITLE>
-<REFMISCINFO>SQL - Language Statements</REFMISCINFO>
-</REFMETA>
-<REFNAMEDIV>
-<REFNAME>
-ABORT
-</REFNAME>
-<REFPURPOSE>
-Aborts the current transaction
-</REFPURPOSE>
-</REFNAMEDIV>
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-09-27</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
-ABORT
-</SYNOPSIS>
+<refentry id="SQL-ABORT">
+ <refmeta>
+ <refentrytitle>
+ ABORT
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ ABORT
+ </refname>
+ <refpurpose>
+ Aborts the current transaction
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-27</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+ABORT [ TRANSACTION | WORK ]
+ </synopsis>
-<REFSECT2 ID="R2-SQL-ABORT-1">
-<REFSECT2INFO>
-<DATE>1998-09-27</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-None.
-</para>
+ <refsect2 id="R2-SQL-ABORT-1">
+ <refsect2info>
+ <date>1998-09-27</date>
+ </refsect2info>
+ <title>
+ Inputs
+ </title>
-</REFSECT2>
+ <para>
+ None.
+ </para>
+ </refsect2>
-<REFSECT2 ID="R2-SQL-ABORT-2">
-<REFSECT2INFO>
-<DATE>1998-09-27</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
+ <refsect2 id="R2-SQL-ABORT-2">
+ <refsect2info>
+ <date>1998-09-27</date>
+ </refsect2info>
+ <title>
+ Outputs
+ </title>
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
- ABORT
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if successful.
-</para>
-</listitem>
-</VARLISTENTRY>
-<VARLISTENTRY>
-<TERM>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+ABORT
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
NOTICE: UserAbortTransactionBlock and not in in-progress state
ABORT
-</TERM>
-<LISTITEM>
-<PARA>
- If there is not any transaction currently in progress.
-</para>
-</listitem>
-</VARLISTENTRY>
-</VARIABLELIST>
-</para>
-</REFSECT2>
-</REFSYNOPSISDIV>
+ </computeroutput></term>
+ <listitem>
+ <para>
+ If there is not any transaction currently in progress.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+ </refsynopsisdiv>
-<REFSECT1 ID="R1-SQL-ABORT-1">
-<REFSECT1INFO>
-<DATE>1998-09-27</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
+ <refsect1 id="R1-SQL-ABORT-1">
+ <refsect1info>
+ <date>1998-09-27</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
<command>ABORT</command> rolls back the current transaction and causes
all the updates made by the transaction to be discarded.
-This command is identical
-in behavior to the <acronym>SQL92</acronym> command <command>ROLLBACK</command>,
-and is present only for historical reasons.
-</para>
-<REFSECT2 ID="R2-SQL-ABORT-3">
-<REFSECT2INFO>
-<DATE>1998-09-27</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<para>
-Use the <command>COMMIT</command> statement to successfully
- terminate a transaction.
-</para>
-</refsect2>
-</REFSECT1>
+ This command is identical
+ in behavior to the <acronym>SQL92</acronym> command <command>ROLLBACK</command>,
+ and is present only for historical reasons.
+ </para>
+ <refsect2 id="R2-SQL-ABORT-3">
+ <refsect2info>
+ <date>1998-09-27</date>
+ </refsect2info>
+ <title>
+ Notes
+ </title>
+ <para>
+ Use <command>COMMIT</command> to successfully
+ terminate a transaction.
+ </para>
+ </refsect2>
+ </refsect1>
-<REFSECT1 ID="R1-SQL-ABORT-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
---To abort all changes
---
+ <refsect1 id="R1-SQL-ABORT-2">
+ <title>
+ Usage
+ </title>
+ <para>
+ To abort all changes:
+ <programlisting>
ABORT WORK;
-</ProgramListing>
-</para>
+ </programlisting>
+ </para>
+
+ </refsect1>
-</REFSECT1>
+ <refsect1 id="R1-SQL-ABORT-3">
+ <title>
+ Compatibility
+ </title>
-<REFSECT1 ID="R1-SQL-ABORT-3">
-<TITLE>
-Compatibility
-</TITLE>
+ <refsect2 id="R2-SQL-ABORT-4">
+ <refsect2info>
+ <date>1998-09-27</date>
+ </refsect2info>
+ <title>
+ SQL92
+ </title>
+ <para>
+ This command is a <productname>Postgres</productname> extension present
+ for historical reasons. <command>ROLLBACK</command> is the <acronym>SQL92</acronym>
+ equivalent command.
+ </para>
+ </refsect2>
+ </refsect1>
-<REFSECT2 ID="R2-SQL-ABORT-4">
-<REFSECT2INFO>
-<DATE>1998-09-27</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<para>
-This command is a <productname>Postgres</productname> extension present
-for historical reasons. <command>ROLLBACK</command> is the <acronym>SQL92</acronym>
-equivalent command.
-</PARA>
-</refsect2>
-</refsect1>
+</refentry>
-</REFENTRY>
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:nil
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:"../reference.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:"/usr/lib/sgml/catalog"
+sgml-local-ecat-files:nil
+End:
+-->
-<REFENTRY ID="SQL-ALTERTABLE">
-<REFMETA>
-<REFENTRYTITLE>
-ALTER TABLE
-</REFENTRYTITLE>
-<REFMISCINFO>SQL - Language Statements</REFMISCINFO>
-</REFMETA>
-<REFNAMEDIV>
-<REFNAME>
-ALTER TABLE
-</REFNAME>
-<REFPURPOSE>
-Modifies table properties
-</REFPURPOSE>
-</refnamediv>
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-04-15</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
-ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- [ * ] ADD [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE>
-ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- [ * ] RENAME [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> TO <REPLACEABLE CLASS="PARAMETER">newcolumn</REPLACEABLE>
-ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- RENAME TO <REPLACEABLE CLASS="PARAMETER">newtable</REPLACEABLE>
-</SYNOPSIS>
+<refentry id="SQL-ALTERTABLE">
+ <refmeta>
+ <refentrytitle>
+ ALTER TABLE
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ ALTER TABLE
+ </refname>
+ <refpurpose>
+ Modifies table properties
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
+ [ * ] ADD [ COLUMN ] <replaceable class="PARAMETER">ER">co</replaceable>BLE> <replaceable
+ class="PARAMETER">type</replaceable>
+ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
+ [ * ] RENAME [ COLUMN ] <replaceable class="PARAMETER">ER">co</replaceable>BLE> TO <replaceable
+ class="PARAMETER">newcolumn</replaceable>
+ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
+ RENAME TO <replaceable class="PARAMETER">newtable</replaceable>
+ </synopsis>
-<REFSECT2 ID="R2-SQL-ALTERTABLE-1">
-<REFSECT2INFO>
-<DATE>1998-04-15</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER"> table </REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- The name of an existing table to alter.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
+ <refsect2 id="R2-SQL-ALTERTABLE-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
+ Inputs
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> table </replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing table to alter.
+ </para>
+ </listitem>
+ </varlistentry>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER"> column </REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- Name of a new or existing column.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> column </replaceable></term>
+ <listitem>
+ <para>
+ Name of a new or existing column.
+ </para>
+ </listitem>
+ </varlistentry>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER"> type </REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- Type of the new column.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> type </replaceable></term>
+ <listitem>
+ <para>
+ Type of the new column.
+ </para>
+ </listitem>
+ </varlistentry>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER"> newcolumn </REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- New name for an existing column.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> newcolumn </replaceable></term>
+ <listitem>
+ <para>
+ New name for an existing column.
+ </para>
+ </listitem>
+ </varlistentry>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER"> newtable </REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- New name for an existing column.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-</VARIABLELIST>
-</para>
-</REFSECT2>
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> newtable </replaceable></term>
+ <listitem>
+ <para>
+ New name for an existing column.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
-<REFSECT2 ID="R2-SQL-ALTERTABLE-2">
-<REFSECT2INFO>
-<DATE>1998-04-15</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
+ <refsect2 id="R2-SQL-ALTERTABLE-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
+ Outputs
+ </title>
+ <para>
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<returnvalue>ALTER</returnvalue>
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned from column or table renaming.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+ALTER
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned from column or table renaming.
+ </para>
+ </listitem>
+ </varlistentry>
-<VARLISTENTRY>
-<TERM>
-<returnvalue>NEW</returnvalue>
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned from column addition.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
+ <varlistentry>
+ <term><computeroutput>
+NEW
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned from column addition.
+ </para>
+ </listitem>
+ </varlistentry>
-<VARLISTENTRY>
-<TERM>
-<ReturnValue>ERROR</ReturnValue>
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if table or column is not available.
-</para>
-</listitem>
-</VARLISTENTRY>
-</VARIABLELIST>
-</para>
-</REFSECT2>
-</REFSYNOPSISDIV>
+ <varlistentry>
+ <term><computeroutput>
+ERROR
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if table or column is not available.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+ </refsynopsisdiv>
-<REFSECT1 ID="R1-SQL-ALTERTABLE-1">
-<REFSECT1INFO>
-<DATE>1998-04-15</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
+ <refsect1 id="R1-SQL-ALTERTABLE-1">
+ <refsect1info>
+ <date>1998-04-15</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
<command>ALTER TABLE</command> changes the definition of an existing table.
The new columns and their types are specified in the same style
and with the the same restrictions as in <command>CREATE TABLE</command>.
the affected table. Thus, the table or column will
remain of the same type and size after this command is
executed.
-</para>
-<PARA>
+ </para>
+
+ <para>
You must own the table in order to change its schema.
-</PARA>
+ </para>
+
+ <refsect2 id="R2-SQL-ALTERTABLE-3">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
+ Notes
+</title>
+ <para>
+ The keyword <literal>COLUMN</literal> is noise and can be omitted.
+ </para>
-<REFSECT2 ID="R2-SQL-ALTERTABLE-3">
-<REFSECT2INFO>
-<DATE>1998-04-15</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-The keyword COLUMN is noise and can be omitted.
-</para>
-<PARA>
-<Quote>[*]</Quote> following a name of a table indicates that statement
- should be run over that table and all tables below it in the
- inheritance hierarchy.
+ <para>
+ <quote>[*]</quote> following a name of a table indicates that statement
+ should be run over that table and all tables below it in the
+ inheritance hierarchy.
The <citetitle>PostgreSQL User's Guide</citetitle> has further
- information on inheritance.
-</para>
+ information on inheritance.
+ </para>
-<PARA>
- Refer to CREATE TABLE for a further description
- of valid arguments.
-</para>
-</REFSECT2>
-</REFSECT1>
+ <para>
+ Refer to <command>CREATE TABLE</command> for a further description
+ of valid arguments.
+ </para>
+ </refsect2>
+ </refsect1>
-<REFSECT1 ID="R1-SQL-ALTERTABLE-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
+ <refsect1 id="R1-SQL-ALTERTABLE-2">
+ <title>
+ Usage
+ </title>
+ <para>
To add a column of type VARCHAR to a table:
-<ProgramListing>
- ALTER TABLE distributors ADD COLUMN address VARCHAR(30);
-</ProgramListing>
-</para>
+ <programlisting>
+ALTER TABLE distributors ADD COLUMN address VARCHAR(30);
+ </programlisting>
+ </para>
-<PARA>
+ <para>
To rename an existing column:
-<ProgramListing>
- ALTER TABLE distributors RENAME COLUMN address TO city;
-</ProgramListing>
-</para>
+ <programlisting>
+ALTER TABLE distributors RENAME COLUMN address TO city;
+ </programlisting>
+ </para>
-<PARA>
+ <para>
To rename an existing table:
-<ProgramListing>
- ALTER TABLE distributors RENAME TO suppliers;
-</ProgramListing>
-</para>
-
-</REFSECT1>
+ <programlisting>
+ALTER TABLE distributors RENAME TO suppliers;
+ </programlisting>
+ </para>
+ </refsect1>
-<REFSECT1 ID="R1-SQL-ALTERTABLE-3">
-<TITLE>
-Compatibility
-</TITLE>
+ <refsect1 id="R1-SQL-ALTERTABLE-3">
+ <title>
+ Compatibility
+ </title>
-<REFSECT2 ID="R2-SQL-ALTERTABLE-4">
-<REFSECT2INFO>
-<DATE>1998-04-15</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
-<command>ALTER TABLE/RENAME</command>
- is a <productname>Postgres</productname> language extension.
-</para>
+ <refsect2 id="R2-SQL-ALTERTABLE-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
+ SQL92
+ </title>
+ <para>
+ <command>ALTER TABLE/RENAME</command>
+ is a <productname>Postgres</productname> language extension.
+ </para>
-<PARA>
- SQL92 specifies some additional capabilities for <command>ALTER TABLE</command>
- statement which are not yet directly supported by
- <ProductName>Postgres</ProductName>:
-</para>
+ <para>
+ SQL92 specifies some additional capabilities for <command>ALTER TABLE</command>
+ statement which are not yet directly supported by
+ <productname>Postgres</productname>:
+ </para>
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<Synopsis>
-ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ALTER [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
- SET DEFAULT <REPLACEABLE CLASS="PARAMETER">default</REPLACEABLE>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <synopsis>
+ALTER TABLE <replaceable class="PARAMETER">table</replaceable> ALTER [
+ COLUMN ] <replaceable class="PARAMETER">column</replaceable>
+ SET DEFAULT <replaceable class="PARAMETER">default</replaceable>
+ALTER TABLE <replaceable class="PARAMETER">table</replaceable> ALTER [
+ COLUMN ] <replaceable class="PARAMETER">column</replaceable>
+ ADD [ CONSTRAINT <replaceable class="PARAMETER">>constrain</replaceable>> ] <replaceable
+ class="PARAMETER">table-constraint</replaceable>
+ </synopsis>
+ </term>
+ <listitem>
+ <para>
+ Puts the default value or constraint specified into the
+ definition of column in the table.
+ See <command>CREATE TABLE</command> for the
+ syntax of the default and table-constraint clauses.
+ If a default clause already exists, it will be replaced by
+ the new definition. If any constraints on this column already
+ exist, they will be retained using a boolean AND with the new
+ constraint.
+ </para>
-ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ALTER [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
- ADD [ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">constraint</REPLACEABLE> ] <REPLACEABLE CLASS="PARAMETER">table-constraint</REPLACEABLE>
-</Synopsis>
-</TERM>
-<LISTITEM>
-<PARA>
- Puts the default value or constraint specified into the
- definition of column in the table.
- See <command>CREATE TABLE</command> for the
- syntax of the default and table-constraint clauses.
- If a default clause already exists, it will be replaced by
- the new definition. If any constraints on this column already
- exist, they will be retained using a boolean AND with the new
- constraint.
-</para>
+ <para>
+ Currently, to set new default constraints on an existing column
+ the table must be recreated and reloaded:
-<PARA>
-Currently, to set new default constraints on an existing column
- the table must be recreated and reloaded:
-
-<ProgramListing>
+ <programlisting>
CREATE TABLE temp AS SELECT * FROM distributors;
DROP TABLE distributors;
CREATE TABLE distributors (
);
INSERT INTO distributors SELECT * FROM temp;
DROP TABLE temp;
-</ProgramListing>
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
+ </programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
-<VARLISTENTRY>
-<TERM>
-<Synopsis>
-ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- DROP DEFAULT <REPLACEABLE CLASS="PARAMETER">default</REPLACEABLE>
-ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- DROP CONSTRAINT <REPLACEABLE CLASS="PARAMETER">constraint</REPLACEABLE> { RESTRICT | CASCADE }
-</Synopsis>
-</TERM>
-<LISTITEM>
-<PARA>
- Removes the default value specified by default or the rule
- specified by constraint from the definition of a table.
- If RESTRICT is specified only a constraint with no dependent
- constraints can be destroyed.
- If CASCADE is specified, Any constraints that are dependent on
- this constraint are also dropped.
-</para>
+ <varlistentry>
+ <term>
+ <synopsis>
+ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
+ DROP DEFAULT <replaceable class="PARAMETER">default</replaceable>
+ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
+ DROP CONSTRAINT <replaceable class="PARAMETER">constraint</replaceable> { RESTRICT | CASCADE }
+ </synopsis>
+ </term>
+ <listitem>
+ <para>
+ Removes the default value specified by default or the rule
+ specified by constraint from the definition of a table.
+ If RESTRICT is specified only a constraint with no dependent
+ constraints can be destroyed.
+ If CASCADE is specified, Any constraints that are dependent on
+ this constraint are also dropped.
+ </para>
-<PARA>
-Currently, to remove a default value or constraints on an
- existing column the table must be recreated and reloaded:
+ <para>
+ Currently, to remove a default value or constraints on an
+ existing column the table must be recreated and reloaded:
-<ProgramListing>
+ <programlisting>
CREATE TABLE temp AS SELECT * FROM distributors;
DROP TABLE distributors;
CREATE TABLE distributors AS SELECT * FROM temp;
DROP TABLE temp;
-</ProgramListing>
-</para>
-</listitem>
-</varlistentry>
-
-<VARLISTENTRY>
-<TERM>
-<Synopsis>
-ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- DROP [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> { RESTRICT | CASCADE }
-</Synopsis>
-</TERM>
-<LISTITEM>
-<PARA>
- Removes a column from a table.
- If RESTRICT is specified only a column with no dependent
- objects can be destroyed.
- If CASCADE is specified, all objects that are dependent on
- this column are also dropped.
-</para>
+ </programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <synopsis>
+ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
+ DROP [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { RESTRICT | CASCADE }
+ </synopsis>
+ </term>
+ <listitem>
+ <para>
+ Removes a column from a table.
+ If RESTRICT is specified only a column with no dependent
+ objects can be destroyed.
+ If CASCADE is specified, all objects that are dependent on
+ this column are also dropped.
+ </para>
-<PARA>
-Currently, to remove an existing column the table must be
- recreated and reloaded:
+ <para>
+ Currently, to remove an existing column the table must be
+ recreated and reloaded:
-<ProgramListing>
+ <programlisting>
CREATE TABLE temp AS SELECT did, city FROM distributors;
DROP TABLE distributors;
CREATE TABLE distributors (
);
INSERT INTO distributors SELECT * FROM temp;
DROP TABLE temp;
-</ProgramListing>
-</PARA>
-</listitem>
-</varlistentry>
-</VARIABLELIST>
-</refsect2>
-</refsect1>
-</REFENTRY>
+ </programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect2>
+ </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:nil
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:"../reference.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:"/usr/lib/sgml/catalog"
+sgml-local-ecat-files:nil
+End:
+-->
- <refentry id="SQL-ALTERUSER">
- <refmeta>
- <refentrytitle>
- ALTER USER
- </refentrytitle>
- <refmiscinfo>SQL - Language Statements</refmiscinfo>
- </refmeta>
- <refnamediv>
- <refname>
- ALTER USER
- </refname>
- <refpurpose>
- Modifies user account information
- </refpurpose>
+<refentry id="SQL-ALTERUSER">
+ <refmeta>
+ <refentrytitle>
+ ALTER USER
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ ALTER USER
+ </refname>
+ <refpurpose>
+ Modifies user account information
+ </refpurpose>
</refnamediv>
- <refsynopsisdiv>
- <refsynopsisdivinfo>
- <date>1998-09-08</date>
- </refsynopsisdivinfo>
- <synopsis>
-ALTER USER <replaceable class="PARAMETER">username</replaceable>
- [ WITH PASSWORD <replaceable class="PARAMETER">password</replaceable> ]
- [ CREATEDB | NOCREATEDB ]
- [ CREATEUSER | NOCREATEUSER ]
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-08</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+ALTER USER <replaceable class="PARAMETER">username</replaceable> [ WITH PASSWORD <replaceable class="PARAMETER">password</replaceable> ]
+ [ CREATEDB | NOCREATEDB ] [ CREATEUSER | NOCREATEUSER ]
[ IN GROUP <replaceable class="PARAMETER">groupname</replaceable> [, ...] ]
[ VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>' ]
- </synopsis>
-
- <refsect2 id="R2-SQL-ALTERUSER-1">
- <refsect2info>
- <date>1998-09-08</date>
- </refsect2info>
- <title>
- Inputs
- </title>
- <para>
- Refer to <command>CREATE USER</command> for a detailed description of each
- clause.
- </para>
- <variablelist>
- <varlistentry>
- <term>
- <replaceable class="PARAMETER"> username </replaceable>
- </term>
- <listitem>
- <para>
- The Postgres account name of the user whose details are to be altered.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="PARAMETER"> password </replaceable>
- </term>
- <listitem>
- <para>
- The new password to be used for this account.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="PARAMETER"> groupname </replaceable>
- </term>
- <listitem>
- <para>
- The name of an access group into which this account is to be put.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="PARAMETER"> abstime </replaceable>
- </term>
- <listitem>
- <para>
- The date (and, optionally, the time)
- at which this user's access is to be terminated.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect2>
+ </synopsis>
+
+ <refsect2 id="R2-SQL-ALTERUSER-1">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
+ Inputs
+ </title>
+
+ <para>
+ Refer to <command>CREATE USER</command> for a detailed description of each
+ clause.
+ </para>
+
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> username </replaceable></term>
+ <listitem>
+ <para>
+ The Postgres account name of the user whose details are to be altered.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> password </replaceable></term>
+ <listitem>
+ <para>
+ The new password to be used for this account.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> groupname </replaceable></term>
+ <listitem>
+ <para>
+ The name of an access group into which this account is to be put.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="PARAMETER"> abstime </replaceable></term>
+ <listitem>
+ <para>
+ The date (and, optionally, the time)
+ at which this user's access is to be terminated.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
- <refsect2 id="R2-SQL-ALTERUSER-2">
- <refsect2info>
- <date>1998-09-08</date>
- </refsect2info>
- <title>
- Outputs
- </title>
+ <refsect2 id="R2-SQL-ALTERUSER-2">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
+ Outputs
+ </title>
<para>
<variablelist>
<varlistentry>
- <term>
- <returnvalue>ALTER USER</returnvalue>
- </term>
+ <term><computeroutput>
+ALTER USER
+ </computeroutput></term>
<listitem>
<para>
Message returned if the alteration was successful.
</varlistentry>
<varlistentry>
- <term>
- <returnvalue>ERROR: alterUser: user "username" does not exist</returnvalue>
- </term>
+ <term><computeroutput>
+ERROR: alterUser: user "username" does not exist
+ </computeroutput></term>
<listitem>
<para>
- Error message returned if the user specified doesn't
- exist.
+ Error message returned if the specified user is not known to
+ the database.
</para>
</listitem>
</varlistentry>
</para>
</refsect2>
</refsynopsisdiv>
-
- <refsect1 id="R1-SQL-ALTERUSER-1">
- <refsect1info>
- <date>1998-09-08</date>
- </refsect1info>
- <title>
- Description
- </title>
- <para>
- <command>ALTER USER</command> is used to change the attributes of a user's
- <productname>Postgres</productname> account.
- Please note that it is not possible
- to alter a user's "usesysid" via the alter user
- statement. Also, it is only possible for the
- <productname>Postgres</productname>
- user or any user with read and modify permissions on
- "pg_shadow" to alter user passwords.
- </para>
- <para>
- If any of the clauses of the alter user statement are
- omitted, the corresponding value in the "pg_shadow" table
- is left unchanged.
- </para>
+
+ <refsect1 id="R1-SQL-ALTERUSER-1">
+ <refsect1info>
+ <date>1998-09-08</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
+ <command>ALTER USER</command> is used to change the attributes of a user's
+ <productname>Postgres</productname> account.
+ Please note that it is not possible
+ to alter a user's "usesysid" via the alter user
+ statement. Also, it is only possible for the
+ <productname>Postgres</productname>
+ user or any user with read and modify permissions on
+ <literal>pg_shadow</literal> to alter user passwords.
+ </para>
+
+ <para>
+ If any of the clauses of the alter user statement are
+ omitted, the corresponding value in the "pg_shadow" table
+ is left unchanged.
+ </para>
- <refsect2 id="R2-SQL-ALTERUSER-3">
- <refsect2info>
- <date>1998-09-08</date>
- </refsect2info>
- <title>
- Notes
- </title>
- <para>
- <command>ALTER USER</command> statement
- is a <productname>Postgres</productname>
- language extension.
- </para>
- <para>
- Refer to <command>CREATE/DROP USER</command>
- to create or remove a user
- account.
- </para>
- <para>
- In the current release (v6.5), the IN GROUP clause is parsed
- but has no affect. When it is fully implemented, it is
- intended to modify the pg_group relation.
- </para>
- </refsect2>
- </refsect1>
-
- <refsect1 id="R1-SQL-ALTERUSER-2">
- <title>
- Usage
- </title>
- <para>
- Change a user password
- </para>
- <programlisting>
+ <refsect2 id="R2-SQL-ALTERUSER-3">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
+ Notes
+ </title>
+ <para>
+ <command>ALTER USER</command>
+ is a <productname>Postgres</productname>
+ language extension.
+ </para>
+ <para>
+ Refer to <command>CREATE/DROP USER</command>
+ to create or remove a user account.
+ </para>
+ <para>
+ In the current release (v6.5), the IN GROUP clause is parsed
+ but has no affect. When it is fully implemented, it is
+ intended to modify the pg_group relation.
+ </para>
+ </refsect2>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-ALTERUSER-2">
+ <title>
+ Usage
+ </title>
+ <para>
+ Change a user password:
+
+ <programlisting>
ALTER USER davide WITH PASSWORD hu8jmn3;
- </programlisting>
- <para>
- Change a user's valid until date
- </para>
- <programlisting>
+ </programlisting>
+
+ Change a user's valid until date
+
+ <programlisting>
ALTER USER manuel VALID UNTIL 'Jan 31 2030';
- </programlisting>
- <para>
- Change a user's valid until date, specifying that his
-authorisation should expire at midday on 4th May 1998 using
-the time zone which is one hour ahead of UTC
- </para>
- <programlisting>
+ </programlisting>
+
+ Change a user's valid until date, specifying that his
+ authorisation should expire at midday on 4th May 1998 using
+ the time zone which is one hour ahead of UTC
+ <programlisting>
ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
- </programlisting>
- <para>
- Give a user the ability to create other users and new databases.
- </para>
- <programlisting>
+ </programlisting>
+
+ Give a user the ability to create other users and new databases.
+
+ <programlisting>
ALTER USER miriam CREATEUSER CREATEDB;
- </programlisting>
- <para>
- Place a user in two groups
- </para>
- <programlisting>
+ </programlisting>
+
+ Place a user in two groups
+
+ <programlisting>
ALTER USER miriam IN GROUP sales, payroll;
- </programlisting>
- </refsect1>
-
- <refsect1 id="R1-SQL-ALTERUSER-3">
- <title>
- Compatibility
- </title>
- <para>
- </para>
+ </programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-ALTERUSER-3">
+ <title>
+ Compatibility
+ </title>
+ <para>
+ </para>
- <refsect2 id="R2-SQL-ALTERUSER-4">
- <refsect2info>
- <date>1998-09-08</date>
- </refsect2info>
- <title>
- SQL92
- </title>
- <para>
- There is no <command>ALTER USER</command> statement in
- <acronym>SQL92</acronym>.
- The standard leaves
- the definition of users to the implementation.
- </para>
- </refsect2>
- </refsect1>
- </refentry>
+ <refsect2 id="R2-SQL-ALTERUSER-4">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
+ SQL92
+ </title>
+ <para>
+ There is no <command>ALTER USER</command> statement in
+ <acronym>SQL92</acronym>.
+ The standard leaves
+ the definition of users to the implementation.
+ </para>
+ </refsect2>
+ </refsect1>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
Inputs
</title>
<para>
- None
+ None.
</para>
</refsect2>
<para>
<variablelist>
<varlistentry>
- <term>
- <returnvalue>BEGIN</returnvalue>
- </term>
+ <term><computeroutput>
+BEGIN
+ </computeroutput></term>
<listitem>
<para>
This signifies that a new transaction has been started.
</listitem>
</varlistentry>
<varlistentry>
- <term>
- <returnvalue>NOTICE: BeginTransactionBlock and not in default state</returnvalue>
- </term>
+ <term><computeroutput>
+NOTICE: BeginTransactionBlock and not in default state
+ </computeroutput></term>
<listitem>
<para>
This indicates that a transaction was already in progress.
-<REFENTRY ID="SQL-CLOSE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CLOSE">
+ <refmeta>
+ <refentrytitle>
CLOSE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CLOSE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Close a cursor
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-08</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
- </SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-08</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+CLOSE <replaceable class="PARAMETER">cursor</replaceable>
+ </synopsis>
- <REFSECT2 ID="R2-SQL-CLOSE-1">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CLOSE-1">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of an open cursor to close.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">cursor</replaceable></term>
+ <listitem>
+ <para>
+ The name of an open cursor to close.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
- </REFSECT2>
+ </refsect2>
- <REFSECT2 ID="R2-SQL-CLOSE-2">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CLOSE-2">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
-<ReturnValue>CLOSE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the cursor is successfully closed.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<ReturnValue>NOTICE PerformPortalClose: portal "<REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>" not found</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This warning is given if
- <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE> is not
- declared or has already been closed.
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CLOSE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the cursor is successfully closed.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+NOTICE PerformPortalClose: portal "<replaceable class="PARAMETER">cursor</replaceable>" not found
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This warning is given if
+ <replaceable class="PARAMETER">cursor</replaceable> is not
+ declared or has already been closed.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CLOSE-1">
- <REFSECT1INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CLOSE-1">
+ <refsect1info>
+ <date>1998-09-08</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CLOSE</command> frees the resources associated with an open cursor.
After the cursor is closed, no subsequent operations
are allowed on it. A cursor should be closed when it is
no longer needed.
- </PARA>
- <PARA>
+ </para>
+ <para>
An implicit close is executed for every open cursor when a
transaction is terminated by <command>COMMIT</command>
or <command>ROLLBACK</command>.
- </PARA>
+ </para>
- <REFSECT2 ID="R2-SQL-CLOSE-3">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CLOSE-3">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
-<productname>Postgres</productname> does not have
- an explicit <command>OPEN</command> cursor statement;
+ </title>
+ <para>
+ <productname>Postgres</productname> does not have
+ an explicit <command>OPEN</command> cursor statement;
a cursor is considered open when it is declared.
Use the <command>DECLARE</command> statement to declare a cursor.
- </PARA>
- </REFSECT2>
+ </para>
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-CLOSE-2">
- <TITLE>
+ <refsect1 id="R1-SQL-CLOSE-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Close the cursor liahona:
- </PARA>
- <ProgramListing>
+ </para>
+ <programlisting>
CLOSE liahona;
- </ProgramListing>
- </REFSECT1>
+ </programlisting>
+ </refsect1>
- <REFSECT1 ID="R1-SQL-CLOSE-3">
- <TITLE>
+ <refsect1 id="R1-SQL-CLOSE-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
+ </title>
+ <para>
+ </para>
- <REFSECT2 ID="R2-SQL-CLOSE-4">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CLOSE-4">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CLOSE</command> is fully compatible with SQL92.
- </PARA>
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
-
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
-<REFENTRY ID="SQL-CLUSTER">
- <REFMETA>
- <REFENTRYTITLE>
- CLUSTER
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
- CLUSTER
- </REFNAME>
- <REFPURPOSE>
- Gives storage clustering advice to the backend
- </REFPURPOSE>
+<refentry id="SQL-CLUSTER">
+ <refmeta>
+ <refentrytitle>
+ CLUSTER
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ CLUSTER
+ </refname>
+ <refpurpose>
+ Gives storage clustering advice to the backend
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-08</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
- CLUSTER <REPLACEABLE CLASS="PARAMETER">indexname</REPLACEABLE> ON <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-CLUSTER-1">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
- Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER">indexname</REPLACEABLE>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of an index.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a table.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CLUSTER-2">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
- Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <returnvalue>CLUSTER</returnvalue>
- </TERM>
- <LISTITEM>
- <PARA>
- The clustering was done successfully.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<returnvalue>ERROR: relation <<REPLACEABLE CLASS="PARAMETER">tablerelation_number</REPLACEABLE>> inherits "invoice"</returnvalue>
- </TERM>
- <LISTITEM>
- <PARA>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-08</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+CLUSTER <replaceable class="PARAMETER">indexname</replaceable> ON <replaceable class="PARAMETER">table</replaceable>
+ </synopsis>
- <comment>
- This is not documented anywhere. It seems not to be possible to
- cluster a table that is inherited.
- </comment>
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <returnvalue>ERROR: Relation x does not exist!</returnvalue>
- </TERM>
- <LISTITEM>
- <PARA>
+ <refsect2 id="R2-SQL-CLUSTER-1">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
+ Inputs
+ </title>
+ <para>
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">indexname</replaceable></term>
+ <listitem>
+ <para>
+ The name of an index.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">table</replaceable></term>
+ <listitem>
+ <para>
+ The name of a table.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CLUSTER-2">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
+ Outputs
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CLUSTER
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The clustering was done successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: relation <<replaceable class="PARAMETER">tablerelation_number</replaceable>> inherits "invoice"
+ </computeroutput></term>
+ <listitem>
+ <para>
+ <comment>
+ This is not documented anywhere. It seems not to be possible to
+ cluster a table that is inherited.
+ </comment>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: Relation x does not exist!
+ </computeroutput></term>
+ <listitem>
+ <para>
+ <comment>
+ The relation complained of was not shown in the error message,
+ which contained a random string instead of the relation name.
+ </comment>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CLUSTER-1">
+ <refsect1info>
+ <date>1998-09-08</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
+ <command>CLUSTER</command> instructs <productname>Postgres</productname>
+ to cluster the class specified
+ by <replaceable class="parameter">classname</replaceable> approximately
+ based on the index specified by
+ <replaceable class="parameter">indexname</replaceable>. The index must
+ already have been defined on
+ <replaceable class="parameter">classname</replaceable>.
+ </para>
+ <para>
+ When a class is clustered, it is physically reordered
+ based on the index information. The clustering is static.
+ In other words, as the class is updated, the changes are
+ not clustered. No attempt is made to keep new instances or
+ updated tuples clustered. If one wishes, one can
+ recluster manually by issuing the command again.
+ </para>
+
+ <refsect2 id="R2-SQL-CLUSTER-3">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
+ Notes
+ </title>
+
+ <para>
+ The table is actually copied to a temporary table in index
+ order, then renamed back to the original name. For this
+ reason, all grant permissions and other indexes are lost
+ when clustering is performed.
+ </para>
- <comment>
- The relation complained of was not shown in the error message,
- which contained a random string instead of the relation name.
- </comment>
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <para>
+ In cases where you are accessing single rows randomly
+ within a table, the actual order of the data in the heap
+ table is unimportant. However, if you tend to access some
+ data more than others, and there is an index that groups
+ them together, you will benefit from using <command>CLUSTER</command>.
+ </para>
+
+ <para>
+ Another place <command>CLUSTER</command> is helpful is in cases where you use an
+ index to pull out several rows from a table. If you are
+ requesting a range of indexed values from a table, or a
+ single indexed value that has multiple rows that match,
+ <command>CLUSTER</command> will help because once the index identifies the
+ heap page for the first row that matches, all other rows
+ that match are probably already on the same heap page,
+ saving disk accesses and speeding up the query.
+ </para>
- </VARIABLELIST>
+ <para>
+ There are two ways to cluster data. The first is with the
+ <command>CLUSTER</command> command, which reorders the original table with
+ the ordering of the index you specify. This can be slow
+ on large tables because the rows are fetched from the heap
+ in index order, and if the heap table is unordered, the
+ entries are on random pages, so there is one disk page
+ retrieved for every row moved. <productname>Postgres</productname> has a cache,
+ but the majority of a big table will not fit in the cache.
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CLUSTER-1">
- <REFSECT1INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT1INFO>
- <TITLE>
- Description
- </TITLE>
- <PARA>
- <command>CLUSTER</command> instructs <productname>Postgres</productname>
-to cluster the class specified
- by <replaceable class="parameter">classname</replaceable> approximately
- based on the index specified by
- <replaceable class="parameter">indexname</replaceable>. The index must
- already have been defined on
-<replaceable class="parameter">classname</replaceable>.
- </PARA>
- <para>
- When a class is clustered, it is physically reordered
- based on the index information. The clustering is static.
- In other words, as the class is updated, the changes are
- not clustered. No attempt is made to keep new instances or
- updated tuples clustered. If one wishes, one can
- recluster manually by issuing the command again.
- </para>
-
- <REFSECT2 ID="R2-SQL-CLUSTER-3">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
- Notes
- </TITLE>
-
- <para>
- The table is actually copied to a temporary table in index
- order, then renamed back to the original name. For this
- reason, all grant permissions and other indexes are lost
- when clustering is performed.
- </para>
-
- <para>
- In cases where you are accessing single rows randomly
- within a table, the actual order of the data in the heap
- table is unimportant. However, if you tend to access some
- data more than others, and there is an index that groups
- them together, you will benefit from using <command>CLUSTER</command>.
- </para>
-
- <para>
- Another place <command>CLUSTER</command> is helpful is in cases where you use an
- index to pull out several rows from a table. If you are
- requesting a range of indexed values from a table, or a
- single indexed value that has multiple rows that match,
- <command>CLUSTER</command> will help because once the index identifies the
- heap page for the first row that matches, all other rows
- that match are probably already on the same heap page,
- saving disk accesses and speeding up the query.
- </para>
-
- <para>
- There are two ways to cluster data. The first is with the
- <command>CLUSTER</command> command, which reorders the original table with
- the ordering of the index you specify. This can be slow
- on large tables because the rows are fetched from the heap
- in index order, and if the heap table is unordered, the
- entries are on random pages, so there is one disk page
- retrieved for every row moved. <productname>Postgres</productname> has a cache,
- but the majority of a big table will not fit in the cache.
- </para>
-
- <para>
- Another way to cluster data is to use
-<programlisting>
+
+ <para>
+ Another way to cluster data is to use
+ <programlisting>
SELECT ... INTO TABLE <replaceable class="parameter">temp</replaceable> FROM ... ORDER BY ...
-</programlisting>
- This uses the <productname>Postgres</productname> sorting code in
- ORDER BY to match the index, and is much faster for
- unordered data. You then drop the old table, use
-<command>ALTER TABLE/RENAME</command>
- to rename <replaceable class="parameter">temp</replaceable> to the old name, and
- recreate any indexes. The only problem is that <acronym>OID</acronym>s
- will not be preserved. From then on, <command>CLUSTER</command> should be
- fast because most of the heap data has already been
- ordered, and the existing index is used.
+ </programlisting>
+ This uses the <productname>Postgres</productname> sorting code in
+ ORDER BY to match the index, and is much faster for
+ unordered data. You then drop the old table, use
+ <command>ALTER TABLE/RENAME</command>
+ to rename <replaceable class="parameter">temp</replaceable> to the old name, and
+ recreate any indexes. The only problem is that <acronym>OID</acronym>s
+ will not be preserved. From then on, <command>CLUSTER</command> should be
+ fast because most of the heap data has already been
+ ordered, and the existing index is used.
</para>
</refsect2>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-CLUSTER-2">
- <TITLE>
+
+ <refsect1 id="R1-SQL-CLUSTER-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Cluster the employees relation on the basis of its salary attribute
- </PARA>
- <ProgramListing>
- CLUSTER emp_ind ON emp
- </ProgramListing>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-CLUSTER-3">
- <TITLE>
+ </para>
+ <programlisting>
+CLUSTER emp_ind ON emp;
+ </programlisting>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-CLUSTER-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
-
- <REFSECT2 ID="R2-SQL-CLUSTER-4">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ </para>
+
+ <refsect2 id="R2-SQL-CLUSTER-4">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
There is no <command>CLUSTER</command> statement in SQL92.
- </PARA>
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
-
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
Inputs
</title>
<para>
- None
+ None.
</para>
</refsect2>
<variablelist>
<varlistentry>
- <term>
- <returnvalue>END</returnvalue>
- </term>
+ <term><computeroutput>
+END
+ </computeroutput></term>
<listitem>
<para>
Message returned if the transaction is successfully committed.
</listitem>
</varlistentry>
<varlistentry>
- <term>
- <returnvalue>NOTICE EndTransactionBlock and not inprogress/abort state</returnvalue>
- </term>
+ <term><computeroutput>
+NOTICE EndTransactionBlock and not inprogress/abort state
+ </computeroutput></term>
<listitem>
<para>
If there is no transaction in progress.
-<REFENTRY ID="SQL-COPY">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-COPY">
+ <refmeta>
+ <refentrytitle>
COPY
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
COPY
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Copies data between files and tables
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-08</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-08</date>
+ </refsynopsisdivinfo>
+ <synopsis>
COPY [ BINARY ] <replaceable class="parameter">table</replaceable> [ WITH OIDS ]
- FROM { '<replaceable class="parameter">filename</replaceable>' | <filename>stdin</filename> }
+ FROM { '<replaceable class="parameter">filename</replaceable>' |
+ <filename>stdin</filename> }
[ USING DELIMITERS '<replaceable class="parameter">delimiter</replaceable>' ]
COPY [ BINARY ] <replaceable class="parameter">table</replaceable> [ WITH OIDS ]
- TO { '<replaceable class="parameter">filename</replaceable>' | <filename>stdout</filename> }
+ TO { '<replaceable class="parameter">filename</replaceable>' |
+ <filename>stdout</filename> }
[ USING DELIMITERS '<replaceable class="parameter">delimiter</replaceable>' ]
- </SYNOPSIS>
+ </synopsis>
- <REFSECT2 ID="R2-SQL-COPY-1">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-COPY-1">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
-BINARY
- </TERM>
- <LISTITEM>
- <PARA>
- Changes the behavior of field formatting, forcing all data to be
- stored or read as binary objects rather than as text.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<replaceable class="parameter">table</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The name of an existing table.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-WITH OIDS
- </TERM>
- <LISTITEM>
- <PARA>
-Copies the internal unique object id (OID) for each row.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<replaceable class="parameter">filename</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The absolute Unix pathname of the input or output file.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<filename>stdin</filename>
- </TERM>
- <LISTITEM>
- <PARA>
-Specifies that input comes from a pipe or terminal.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<filename>stdout</filename>
- </TERM>
- <LISTITEM>
- <PARA>
-Specifies that output goes to a pipe or terminal.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">delimiter</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term>BINARY</term>
+ <listitem>
+ <para>
+ Changes the behavior of field formatting, forcing all data to be
+ stored or read as binary objects rather than as text.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">table</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing table.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>WITH OIDS</term>
+ <listitem>
+ <para>
+ Copies the internal unique object id (OID) for each row.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">filename</replaceable></term>
+ <listitem>
+ <para>
+ The absolute Unix pathname of the input or output file.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><filename>stdin</filename></term>
+ <listitem>
+ <para>
+ Specifies that input comes from a pipe or terminal.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><filename>stdout</filename></term>
+ <listitem>
+ <para>
+ Specifies that output goes to a pipe or terminal.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">delimiter</replaceable></term>
+ <listitem>
+ <para>
A character that delimits the input or output fields.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
- </REFSECT2>
+ </refsect2>
- <REFSECT2 ID="R2-SQL-COPY-2">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-COPY-2">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>COPY</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The copy completed successfully.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: <replaceable>error message</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+COPY
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The copy completed successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: <replaceable>error message</replaceable>
+ </computeroutput></term>
+ <listitem>
+ <para>
The copy failed for the reason stated in the error message.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
+ </refsect2>
+ </refsynopsisdiv>
- <REFSECT1 ID="R1-SQL-COPY-1">
- <REFSECT1INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT1INFO>
- <TITLE>
+ <refsect1 id="R1-SQL-COPY-1">
+ <refsect1info>
+ <date>1998-09-08</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
+ </title>
<para>
<command>COPY</command> moves data between
- <productname>Postgres</productname> tables and
+ <productname>Postgres</productname> tables and
standard Unix files.
<command>COPY</command> instructs
the <productname>Postgres</productname> backend
to directly read from or write to a file. The file must be directly visible to
the backend and the name must be specified from the viewpoint of the backend.
- If <filename>stdin</filename> or <filename>stdout</filename> are specified, data flows through the client frontend to
- the backend.
- </para>
- <REFSECT2 ID="R2-SQL-COPY-3">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ If <filename>stdin</filename> or <filename>stdout</filename> are
+ specified, data flows through the client frontend to the backend.
+ </para>
+
+ <refsect2 id="R2-SQL-COPY-3">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
+ </title>
<para>
The BINARY keyword will force all data to be
stored/read as binary objects rather than as text. It is
The backend also needs appropriate Unix permissions for any file read
or written by <command>COPY</command>.
</para>
+
<para>
The keyword phrase USING DELIMITERS specifies a single character
to be used for all delimiters between columns. If multiple characters
</para>
</tip>
</para>
- </REFSECT2>
+ </refsect2>
</refsect1>
- <refsect1 ID="R1-SQL-COPY-2">
+ <refsect1 id="R1-SQL-COPY-2">
<refsect1info>
<date>1998-05-04</date>
</refsect1info>
The actual format for each instance is
<programlisting>
<attr1><<replaceable class=parameter>separator</replaceable>><attr2><<replaceable class=parameter>separator</replaceable>>...<<replaceable class=parameter>separator</replaceable>><attr<replaceable class="parameter">n</replaceable>><newline>
-</programlisting>
+ </programlisting>
The oid is placed on the beginning of the line
- if WITH OIDS is specified.
+ if WITH OIDS is specified.
</para>
<para>
If <command>COPY</command> is sending its output to standard
as a backslash and a tab. A literal newline character is
represented as a backslash and a newline. When loading text data
not generated by <acronym>Postgres</acronym>,
- you will need to convert backslash
+ you will need to convert backslash
characters ("\") to double-backslashes ("\\") to ensure that they are loaded
properly.
</para>
</para>
<table frame="all">
<title>Contents of a binary copy file</title>
- <tgroup cols="2"colsep="1" rowsep="1" align="center">
- <COLSPEC COLNAME="col1">
- <COLSPEC COLNAME="col2">
+ <tgroup cols="2" colsep="1" rowsep="1" align="center">
+ <colspec colname="col1">
+ <colspec colname="col2">
<spanspec namest="col1" nameend="col2" spanname="subhead">
<tbody>
<row>
- <entry align="center" spanname="subhead">At the start of the file</entry>
+ <entry spanname="subhead" align="center">At the start of the file</entry>
</row>
<row>
<entry>uint32</entry>
<entry>number of tuples</entry>
</row>
<row>
- <entry align="center" spanname="subhead">For each tuple</entry>
+ <entry spanname="subhead" align="center">For each tuple</entry>
</row>
<row>
<entry>uint32</entry>
</refsect1>
- <REFSECT1 ID="R1-SQL-COPY-3">
- <TITLE>
+ <refsect1 id="R1-SQL-COPY-3">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
The following example copies a table to standard output,
using a vertical bar ("|") as the field
delimiter:
- </PARA>
- <ProgramListing>
+ </para>
+ <programlisting>
COPY country TO <filename>stdout</filename> USING DELIMITERS '|';
- </ProgramListing>
- <PARA>
+ </programlisting>
+ <para>
To copy data from a Unix file into a table "country":
- </PARA>
- <ProgramListing>
+ </para>
+ <programlisting>
COPY country FROM '/usr1/proj/bray/sql/country_data';
- </ProgramListing>
- <PARA>
+ </programlisting>
+ <para>
Here is a sample of data suitable for copying into a table
from <filename>stdin</filename> (so it
has the termination sequence on the last line):
- </PARA>
- <ProgramListing>
+ </para>
+ <programlisting>
AF AFGHANISTAN
AL ALBANIA
DZ ALGERIA
ZM ZAMBIA
ZW ZIMBABWE
\.
- </ProgramListing>
- <PARA>
+ </programlisting>
+ <para>
The same data, output in binary format on a Linux/i586 machine.
The data is shown after filtering through
the Unix utility <command>od -c</command>. The table has
Notice how the <classname>char(2)</classname>
field is padded with nulls to four bytes and the text field is
preceded by its length:
- </PARA>
- <ProgramListing>
+ </para>
+ <programlisting>
355 \0 \0 \0 027 \0 \0 \0 001 \0 \0 \0 002 \0 \0 \0
006 \0 \0 \0 A F \0 \0 017 \0 \0 \0 A F G H
A N I S T A N 023 \0 \0 \0 001 \0 \0 \0 002
... \n \0 \0 \0 Z A M B I A 024 \0
\0 \0 001 \0 \0 \0 002 \0 \0 \0 006 \0 \0 \0 Z W
\0 \0 \f \0 \0 \0 Z I M B A B W E
- </ProgramListing>
+ </programlisting>
</refsect1>
- <refsect1 ID="R1-SQL-COPY-5">
+ <refsect1 id="R1-SQL-COPY-5">
<title>Bugs and features</title>
<para>
<command>COPY</command> neither invokes rules nor acts on column defaults.
</para>
</refsect1>
- <REFSECT1 ID="R1-SQL-COPY-6">
- <TITLE>
+ <refsect1 id="R1-SQL-COPY-6">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
+ </title>
+ <para>
+ </para>
- <REFSECT2 ID="R2-SQL-COPY-4">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-COPY-4">
+ <refsect2info>
+ <date>1998-09-08</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
There is no <command>COPY</command> statement in SQL92.
- </PARA>
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-CREATEAGGREGATE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATEAGGREGATE">
+ <refmeta>
+ <refentrytitle>
CREATE AGGREGATE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
- <REFNAMEDIV>
- <REFNAME>
+ <refnamediv>
+ <refname>
CREATE AGGREGATE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Defines a new aggregate function
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-09</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-CREATE AGGREGATE <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> [ AS ]
- ( BASETYPE = <REPLACEABLE CLASS="PARAMETER">data_type</REPLACEABLE>
- [ , SFUNC1 = <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>
- , STYPE1 = <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE> ]
- [ , SFUNC2 = <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>
- , STYPE2 = <REPLACEABLE CLASS="PARAMETER">sfunc2_return_type</REPLACEABLE> ]
- [ , FINALFUNC = <REPLACEABLE CLASS="PARAMETER">ffunc</REPLACEABLE> ]
- [ , INITCOND1 = <REPLACEABLE CLASS="PARAMETER">initial_condition1</REPLACEABLE> ]
- [ , INITCOND2 = <REPLACEABLE CLASS="PARAMETER">initial_condition2</REPLACEABLE> ]
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-09</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> [ AS ]
+ ( BASETYPE = <replaceable class="PARAMETER">data_type</replaceable>
+ [ , SFUNC1 = <replaceable class="PARAMETER">sfunc1</replaceable>
+ , STYPE1 = <replaceable class="PARAMETER">sfunc1_return_type</replaceable> ]
+ [ , SFUNC2 = <replaceable class="PARAMETER">sfunc2</replaceable>
+ , STYPE2 = <replaceable class="PARAMETER">sfunc2_return_type</replaceable> ]
+ [ , FINALFUNC = <replaceable class="PARAMETER">ffunc</replaceable> ]
+ [ , INITCOND1 = <replaceable class="PARAMETER">initial_condition1</replaceable> ]
+ [ , INITCOND2 = <replaceable class="PARAMETER">initial_condition2</replaceable> ]
)
- </SYNOPSIS>
+ </synopsis>
- <REFSECT2 ID="R2-SQL-CREATEAGGREGATE-1">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEAGGREGATE-1">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE>
- </TERM>
- <LISTITEM>
- <para>
- The name of an aggregate function to create.
- </para>
- </LISTITEM>
- </varlistentry>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of an aggregate function to create.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <REPLACEABLE CLASS="PARAMETER">data_type</REPLACEABLE>
- </term>
- <listitem>
- <para>
-The fundamental data type on which this aggregate function operates.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">data_type</replaceable></term>
+ <listitem>
+ <para>
+ The fundamental data type on which this aggregate function operates.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>
- </term>
- <listitem>
- <para>
-The state transition function
- to be called for every non-NULL field from the source column.
- It takes a variable of
-type <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE> as
-the first argument and that field as the
-second argument.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">sfunc1</replaceable></term>
+ <listitem>
+ <para>
+ The state transition function
+ to be called for every non-NULL field from the source column.
+ It takes a variable of
+ type <replaceable class="PARAMETER">sfunc1_return_type</replaceable> as
+ the first argument and that field as the
+ second argument.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE>
- </term>
- <listitem>
- <para>
-The return type of the first transition function.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">sfunc1_return_type</replaceable></term>
+ <listitem>
+ <para>
+ The return type of the first transition function.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>
- </term>
- <listitem>
- <para>
-The state transition function
- to be called for every non-NULL field from the source column.
-It takes a variable
-of type <REPLACEABLE CLASS="PARAMETER">sfunc2_return_type</REPLACEABLE>
-as the only argument and returns a variable of the same type.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">sfunc2</replaceable></term>
+ <listitem>
+ <para>
+ The state transition function
+ to be called for every non-NULL field from the source column.
+ It takes a variable
+ of type <replaceable class="PARAMETER">sfunc2_return_type</replaceable>
+ as the only argument and returns a variable of the same type.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <REPLACEABLE CLASS="PARAMETER">sfunc2_return_type</REPLACEABLE>
- </term>
- <listitem>
- <para>
-The return type of the second transition function.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">sfunc2_return_type</replaceable></term>
+ <listitem>
+ <para>
+ The return type of the second transition function.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <REPLACEABLE CLASS="PARAMETER">ffunc</REPLACEABLE>
- </term>
- <listitem>
- <para>
-The final function
- called after traversing all input fields. This function must
-take two arguments of types
- <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE>
-and
-<REPLACEABLE CLASS="PARAMETER">sfunc2_return_type</REPLACEABLE>.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">ffunc</replaceable></term>
+ <listitem>
+ <para>
+ The final function
+ called after traversing all input fields. This function must
+ take two arguments of types
+ <replaceable class="PARAMETER">sfunc1_return_type</replaceable>
+ and
+ <replaceable class="PARAMETER">sfunc2_return_type</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <REPLACEABLE CLASS="PARAMETER">initial_condition1</REPLACEABLE>
- </term>
- <listitem>
- <para>
-The initial value for the first transition function argument.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">initial_condition1</replaceable></term>
+ <listitem>
+ <para>
+ The initial value for the first transition function argument.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <REPLACEABLE CLASS="PARAMETER">initial_condition2</REPLACEABLE>
- </term>
- <listitem>
- <para>
-The initial value for the second transition function argument.
- </para>
- </listitem>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">initial_condition2</replaceable></term>
+ <listitem>
+ <para>
+ The initial value for the second transition function argument.
+ </para>
+ </listitem>
</varlistentry>
</variablelist>
</para>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATEAGGREGATE-2">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CREATEAGGREGATE-2">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
-
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
Message returned if the command completes successfully.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATEAGGREGATE-1">
- <REFSECT1INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATEAGGREGATE-1">
+ <refsect1info>
+ <date>1998-09-09</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
+ </title>
<para>
<command>CREATE AGGREGATE</command>
allows a user or programmer to extend <productname>Postgres</productname>
already provided then <command>CREATE AGGREGATE</command>
can be used to provide the desired features.
</para>
- <PARA>
+ <para>
An aggregate function can require up to three functions, two
state transition functions,
- <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>
- and <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>:
+ <replaceable class="PARAMETER">sfunc1</replaceable>
+ and <replaceable class="PARAMETER">sfunc2</replaceable>:
<programlisting>
- <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>( internal-state1, next-data_item ) ---> next-internal-state1
- <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>( internal-state2 ) ---> next-internal-state2
+<replaceable class="PARAMETER">sfunc1</replaceable>( internal-state1, next-data_item ) ---> next-internal-state1 <replaceable class="PARAMETER">sfunc2</replaceable>( internal-state2 ) ---> next-internal-state2
</programlisting>
and a final calculation function,
- <REPLACEABLE CLASS="PARAMETER">ffunc</REPLACEABLE>:
+ <replaceable class="PARAMETER">ffunc</replaceable>:
<programlisting>
- <REPLACEABLE CLASS="PARAMETER">ffunc</REPLACEABLE>(internal-state1, internal-state2) ---> aggregate-value
+<replaceable class="PARAMETER">ffunc</replaceable>(internal-state1, internal-state2) ---> aggregate-value
</programlisting>
</para>
<para>
<productname>Postgres</productname> creates up to two temporary variables
- (referred to here as <REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
- and <REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>)
+ (referred to here as <replaceable class="PARAMETER">temp1</replaceable>
+ and <replaceable class="PARAMETER">temp2</replaceable>)
to hold intermediate results used as arguments to the transition functions.
</para>
<para>
<listitem>
<para>
The arguments to
- <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>
+ <replaceable class="PARAMETER">sfunc1</replaceable>
must be
- <REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
+ <replaceable class="PARAMETER">temp1</replaceable>
of type
- <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE>
+ <replaceable class="PARAMETER">sfunc1_return_type</replaceable>
and
- <REPLACEABLE CLASS="PARAMETER">column_value</REPLACEABLE>
- of type <REPLACEABLE CLASS="PARAMETER">data_type</REPLACEABLE>.
+ <replaceable class="PARAMETER">column_value</replaceable>
+ of type <replaceable class="PARAMETER">data_type</replaceable>.
The return value must be of type
- <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE>
+ <replaceable class="PARAMETER">sfunc1_return_type</replaceable>
and will be used as the first argument in the next call to
- <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>.
+ <replaceable class="PARAMETER">sfunc1</replaceable>.
</para>
</listitem>
<listitem>
<para>
The argument and return value of
- <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>
+ <replaceable class="PARAMETER">sfunc2</replaceable>
must be
- <REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>
+ <replaceable class="PARAMETER">temp2</replaceable>
of type
- <REPLACEABLE CLASS="PARAMETER">sfunc2_return_type</REPLACEABLE>.
+ <replaceable class="PARAMETER">sfunc2_return_type</replaceable>.
</para>
</listitem>
<listitem>
<para>
The arguments to the final-calculation-function
must be
- <REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
+ <replaceable class="PARAMETER">temp1</replaceable>
and
- <REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>
+ <replaceable class="PARAMETER">temp2</replaceable>
and its return value must
be a <productname>Postgres</productname>
base type (not necessarily
- <REPLACEABLE CLASS="PARAMETER">data_type</REPLACEABLE>
+ <replaceable class="PARAMETER">data_type</replaceable>
which had been specified for BASETYPE).
</para>
</listitem>
FINALFUNC should be specified
if and only if both state-transition functions are
specified.
- </para
- </listitem>
+ </para></listitem>
</itemizedlist>
- </PARA>
+ </para>
<para>
An aggregate function may also require one or two initial conditions,
in the database as fields of type <type>text</type>.
</para>
- <REFSECT2 ID="R2-SQL-CREATEAGGREGATE-3">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEAGGREGATE-3">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
+ </title>
<para>
Use <command>DROP AGGREGATE</command>
- to drop aggregate functions.
+ to drop aggregate functions.
</para>
- <para>
- It is possible to specify aggregate functions
- that have varying combinations of state and final functions.
- For example, the <function>count</function> aggregate requires SFUNC2
- (an incrementing function) but not SFUNC1 or FINALFUNC,
- whereas the <function>sum</function> aggregate requires SFUNC1 (an addition
- function) but not SFUNC2 or FINALFUNC and the <function>avg</function>
- aggregate requires
- both of the above state functions as
- well as a FINALFUNC (a division function) to produce its
- answer. In any case, at least one state function must be
- defined, and any SFUNC2 must have a corresponding INITCOND2.
+ <para>
+ It is possible to specify aggregate functions
+ that have varying combinations of state and final functions.
+ For example, the <function>count</function> aggregate requires SFUNC2
+ (an incrementing function) but not SFUNC1 or FINALFUNC,
+ whereas the <function>sum</function> aggregate requires SFUNC1 (an addition
+ function) but not SFUNC2 or FINALFUNC and the <function>avg</function>
+ aggregate requires
+ both of the above state functions as
+ well as a FINALFUNC (a division function) to produce its
+ answer. In any case, at least one state function must be
+ defined, and any SFUNC2 must have a corresponding INITCOND2.
</para>
-
- </REFSECT2>
+
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATEAGGREGATE-2">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEAGGREGATE-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Refer to the chapter on aggregate functions
in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
on aggregate functions for
complete examples of usage.
</para>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-CREATEAGGREGATE-3">
- <TITLE>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-CREATEAGGREGATE-3">
+ <title>
Compatibility
- </TITLE>
-
- <REFSECT2 ID="R2-SQL-CREATEAGGREGATE-4">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+
+ <refsect2 id="R2-SQL-CREATEAGGREGATE-4">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE AGGREGATE</command>
is a <productname>Postgres</productname> language extension.
There is no <command>CREATE AGGREGATE</command> in SQL92.
- </PARA>
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-CREATEDATABASE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATEDATABASE">
+ <refmeta>
+ <refentrytitle>
CREATE DATABASE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE DATABASE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Creates a new database
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-CREATE DATABASE <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> [ WITH LOCATION = '<replaceable class="parameter">dbpath</replaceable>' ]
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-CREATEDATABASE-1">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> [ WITH LOCATION = '<replaceable class="parameter">dbpath</replaceable>' ]
+ </synopsis>
+
+ <refsect2 id="R2-SQL-CREATEDATABASE-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a database to create.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">dbpath</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- An alternate location can be specified as either an
- environment variable known to the backend server
- (e.g. '<envar>PGDATA2</envar>') or as an absolute path name
- (e.g. '<filename>/usr/local/pgsql/data</filename>').
- In either case, the location must be pre-configured
- by <command>initlocation</command>.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of a database to create.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">dbpath</replaceable></term>
+ <listitem>
+ <para>
+ An alternate location can be specified as either an
+ environment variable known to the backend server
+ (e.g. '<envar>PGDATA2</envar>') or as an absolute path name
+ (e.g. '<filename>/usr/local/pgsql/data</filename>').
+ In either case, the location must be pre-configured
+ by <command>initlocation</command>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATEDATABASE-2">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CREATEDATABASE-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATEDB</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the command completes successfully.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>WARN: createdb: database "<replaceable class="parameter">name</replaceable>" already exists.</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This occurs if <replaceable class="parameter">database</replaceable> specified already exists.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: Unable to create database directory <replaceable class="parameter">directory</replaceable>
- </ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATEDB
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the command completes successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+WARN: createdb: database "<replaceable class="parameter">name</replaceable>" already exists.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This occurs if <replaceable class="parameter">database</replaceable> specified already exists.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: Unable to create database directory <replaceable class="parameter">directory</replaceable>
+ </computeroutput></term>
+ <listitem>
+ <para>
There was a problem with creating the required directory; this operation will
need permissions for the <literal>postgres</literal> user on the specified location.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATEDATABASE-1">
- <REFSECT1INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATEDATABASE-1">
+ <refsect1info>
+ <date>1998-04-15</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE DATABASE</command> creates a new Postgres database.
The creator becomes the administrator of the new database.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-CREATEDATABASE-3">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-CREATEDATABASE-3">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE DATABASE</command> is a <productname>Postgres</productname>
- language extension.
- </PARA>
+ language extension.
+ </para>
<para>
Use <command>DROP DATABASE</command> to remove a database.
</para>
- </REFSECT2>
+ </refsect2>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-CREATEDATABASE-2">
- <TITLE>
+
+ <refsect1 id="R1-SQL-CREATEDATABASE-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
To create a new database:
- </PARA>
- <ProgramListing>
- <prompt>olly=></prompt> <userinput>create database lusiadas;</userinput>
- </ProgramListing>
- <PARA>
+
+ <programlisting>
+<prompt>olly=></prompt> <userinput>create database lusiadas;</userinput>
+ </programlisting>
+ </para>
+
+ <para>
To create a new database in an alternate area <filename>~/private_db</filename>:
- </PARA>
- <ProgramListing>
- <prompt>$</prompt> <userinput>mkdir private_db</userinput>
- <prompt>$</prompt> <userinput>initlocation ~/private_db</userinput>
- <computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
+
+ <programlisting>
+<prompt>$</prompt> <userinput>mkdir private_db</userinput>
+<prompt>$</prompt> <userinput>initlocation ~/private_db</userinput>
+<computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
<prompt>$</prompt> <userinput>psql olly</userinput>
<computeroutput>Welcome to the POSTGRESQL interactive sql monitor:
<prompt>olly=></prompt></computeroutput> <userinput>create database elsewhere with location = '/home/olly/private_db';</userinput>
<computeroutput>CREATEDB</computeroutput>
- </ProgramListing>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-CREATEDATABASE-3">
- <TITLE>
+ </programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-CREATEDATABASE-3">
+ <title>
Bugs
- </TITLE>
- <PARA>
+ </title>
+ <para>
There are security and data integrity issues
- involved with using alternate database locations
+ involved with using alternate database locations
specified with absolute path names, and by default
-only an environment variable known to the backend may be
-specified for an alternate location.
- See the Administrator's Guide for more information.
- </PARA>
+ only an environment variable known to the backend may be
+ specified for an alternate location.
+ See the Administrator's Guide for more information.
+ </para>
</refsect1>
<!--
Not sure if the dump/reload would guarantee that the alternate data area gets refreshed though...
-->
- <REFSECT1 ID="R1-SQL-CREATEDATABASE-4">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEDATABASE-4">
+ <title>
Compatibility
- </TITLE>
-
- <REFSECT2 ID="R2-SQL-CREATEDATABASE-4">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+
+ <refsect2 id="R2-SQL-CREATEDATABASE-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
There is no <command>CREATE DATABASE</command> statement in SQL92.
- </PARA>
+ </para>
<para>
The equivalent command in standard SQL is <command>CREATE SCHEMA</command>.
</para>
</refsect2>
</refsect1>
-</REFENTRY>
-
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
Inputs
</title>
<para>
- <variablelist>
- <varlistentry>
- <term>
- <replaceable class="parameter">name</replaceable>
- </term>
- <listitem>
- <para>
- The name of a function to create.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <replaceable class="parameter">ftype</replaceable>
- </term>
- <listitem>
- <para>
- The data type of function arguments.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <replaceable class="parameter">rtype</replaceable>
- </term>
- <listitem>
- <para>
- The return data type.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <replaceable class="parameter">definition</replaceable>
- </term>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of a function to create.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">ftype</replaceable></term>
+ <listitem>
+ <para>
+ The data type of function arguments.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">rtype</replaceable></term>
+ <listitem>
+ <para>
+ The return data type.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">definition</replaceable></term>
<listitem>
<para>
A string defining the function; the meaning depends on the language.
</listitem>
</varlistentry>
<varlistentry>
- <term>
- <replaceable class="parameter">langname</replaceable>
- </term>
+ <term><replaceable class="parameter">langname</replaceable></term>
<listitem>
<para>
may be '<literal>C</literal>', '<literal>sql</literal>',
</variablelist>
</para>
</refsect2>
-
+
<refsect2 id="R2-SQL-CREATEFUNCTION-2">
<refsect2info>
<date>1998-09-09</date>
Outputs
</title>
<para>
-
+
<variablelist>
<varlistentry>
- <term>
- <returnvalue>CREATE</returnvalue>
- </term>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
<listitem>
<para>
This is returned if the command completes successfully.
</para>
</refsect2>
</refsynopsisdiv>
-
+
<refsect1 id="R1-SQL-CREATEFUNCTION-1">
<refsect1info>
<date>1998-09-09</date>
</title>
<para>
To create a simple SQL function:
- </para>
+
<programlisting>
- CREATE FUNCTION one() RETURNS int4
- AS 'SELECT 1 AS RESULT'
- LANGUAGE 'sql';
-
- SELECT one() AS answer;
-
+CREATE FUNCTION one() RETURNS int4
+ AS 'SELECT 1 AS RESULT'
+ LANGUAGE 'sql';
+SELECT one() AS answer;
+
<computeroutput>
answer
------
1
</computeroutput>
</programlisting>
+ </para>
+
<para>
To create a C function, calling a routine from a user-created
shared library. This particular routine calculates a check
</para>
<programlisting>
<userinput>
- CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
- AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c';
+CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
+ AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c';
- CREATE TABLE product (
+CREATE TABLE product (
id char(8) PRIMARY KEY,
eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}')
REFERENCES brandname(ean_prefix),
eancode char(6) CHECK (eancode ~ '[0-9]{6}'),
CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode))
- );
+);
</userinput>
</programlisting>
</refsect1>
A C function cannot return a set of values.
</para>
</refsect1>
-
+
<refsect1 id="R1-SQL-CREATEFUNCTION-4">
<title>
Compatibility
</title>
- <para>
- <command>CREATE FUNCTION</command> is
- a <productname>Postgres</productname> language extension.
+ <para>
+ <command>CREATE FUNCTION</command> is
+ a <productname>Postgres</productname> language extension.
</para>
-
+
<refsect2 id="R2-SQL-CREATEFUNCTION-4">
<refsect2info>
<date>1998-09-09</date>
</title>
<para>
-<note>
+ <note>
<para>
PSM stands for Persistent Stored Modules. It is a procedural
language and it was originally hoped that PSM would be ratified
as an official standard by late 1996. As of mid-1998, this
-has not yet happened, but it is hoped that PSM will
+ has not yet happened, but it is hoped that PSM will
eventually become a standard.
</para>
-</note>
+ </note>
-SQL/PSM <command>CREATE FUNCTION</command> has the following syntax:
-<synopsis>
+ SQL/PSM <command>CREATE FUNCTION</command> has the following syntax:
+ <synopsis>
CREATE FUNCTION <replaceable class="parameter">name</replaceable>
- ( [ [ IN | OUT | INOUT ] <replaceable class="parameter">eter</replaceable>eable> <replaceable
+ ( [ [ IN | OUT | INOUT ] <replaceable class="parameter">eter</replaceable>eable>eable> <replaceable
class="parameter">type</replaceable> [, ...] ] )
RETURNS <replaceable class="parameter">rtype</replaceable>
LANGUAGE '<replaceable class="parameter">langname</replaceable>'
ESPECIFIC <replaceable class="parameter">routine</replaceable>
<replaceable class="parameter">SQL-statement</replaceable>
-</synopsis>
-
+ </synopsis>
</para>
</refsect2>
</refsect1>
-<REFENTRY ID="SQL-CREATEINDEX">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATEINDEX">
+ <refmeta>
+ <refentrytitle>
CREATE INDEX
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE INDEX
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Constructs a secondary index
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-09</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-09</date>
+ </refsynopsisdivinfo>
+ <synopsis>
CREATE [ UNIQUE ] INDEX <replaceable class="parameter">index_name</replaceable>
ON <replaceable class="parameter">table</replaceable> [ USING <replaceable class="parameter">acc_name</replaceable> ]
( <replaceable class="parameter">column</replaceable> [ <replaceable class="parameter">ops_name</replaceable>] [, ...] )
CREATE [ UNIQUE ] INDEX <replaceable class="parameter">index_name</replaceable>
ON <replaceable class="parameter">table</replaceable> [ USING <replaceable class="parameter">acc_name</replaceable> ]
- ( <replaceable class="parameter">func_name</replaceable>( <replaceable class="parameter">column</replaceable> [, ... ]) <replaceable class="parameter">ops_name</replaceable> )
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-CREATEINDEX-1">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ ( <replaceable class="parameter">func_name</replaceable>( <replaceable class="parameter">r">col</replaceable>le> [, ... ]) <replaceable class="parameter">ops_name</replaceable> )
+ </synopsis>
+
+ <refsect2 id="R2-SQL-CREATEINDEX-1">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- UNIQUE
- </TERM>
- <LISTITEM>
- <PARA>
- Causes the system to check for
- duplicate values in the table when the index is created (if data
- already exist) and each time data is added. Attempts to
- insert or update non-duplicate data will generate an
- error.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">index_name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of the index to be created.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">table</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of the table to be indexed.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">acc_name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- the name of the access method which is to be used for
- the index. The default access method is BTREE.
- Postgres provides three access methods for secondary indexes:
- <variablelist>
- <varlistentry>
- <term>BTREE</term>
- <listitem>
- <para>
- an implementation of the Lehman-Yao
- high-concurrency btrees.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>RTREE</term>
- <listitem>
- <para>implements standard rtrees using Guttman's
- quadratic split algorithm.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>HASH</term>
- <listitem>
- <para>
- an implementation of Litwin's linear hashing.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">column</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a column of the table.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">ops_name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- An associated operator class.
- The following select list returns all ops_names:
-
-<programlisting>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term>UNIQUE</term>
+ <listitem>
+ <para>
+ Causes the system to check for
+ duplicate values in the table when the index is created (if data
+ already exist) and each time data is added. Attempts to
+ insert or update non-duplicate data will generate an
+ error.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">index_name</replaceable></term>
+ <listitem>
+ <para>
+ The name of the index to be created.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">table</replaceable></term>
+ <listitem>
+ <para>
+ The name of the table to be indexed.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">acc_name</replaceable></term>
+ <listitem>
+ <para>
+ the name of the access method which is to be used for
+ the index. The default access method is BTREE.
+ Postgres provides three access methods for secondary indexes:
+ <variablelist>
+ <varlistentry>
+ <term>BTREE</term>
+ <listitem>
+ <para>
+ an implementation of the Lehman-Yao
+ high-concurrency btrees.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>RTREE</term>
+ <listitem>
+ <para>implements standard rtrees using Guttman's
+ quadratic split algorithm.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>HASH</term>
+ <listitem>
+ <para>
+ an implementation of Litwin's linear hashing.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">column</replaceable></term>
+ <listitem>
+ <para>
+ The name of a column of the table.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">ops_name</replaceable></term>
+ <listitem>
+ <para>
+ An associated operator class.
+ The following select list returns all ops_names:
+
+ <programlisting>
SELECT am.amname AS acc_name,
opc.opcname AS ops_name,
opr.oprname AS ops_comp
amop.amopclaid = opc.oid AND
amop.amopopr = opr.oid
ORDER BY acc_name, ops_name, ops_comp
-</programlisting>
-
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">func_name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
+ </programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">func_name</replaceable></term>
+ <listitem>
+ <para>
A user-defined function, which returns a value that can
be indexed.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATEINDEX-2">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CREATEINDEX-2">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The message returned if the index is successfully created.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The message returned if the index is successfully created.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: Cannot create index: 'index_name' already exists.</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: Cannot create index: 'index_name' already exists.
+ </computeroutput></term>
+ <listitem>
+ <para>
This error occurs if it is impossible to create the index.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATEINDEX-1">
- <REFSECT1INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATEINDEX-1">
+ <refsect1info>
+ <date>1998-09-09</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE INDEX</command> constructs an index
<replaceable class="parameter">index_name</replaceable>.
on the specified
<replaceable class="parameter">table</replaceable>.
-
+
<tip>
<para>
Indexes are primarily used to enhance database performance.
operator class is the appropriate operator class for that
field type.
</para>
- <para>
- In the second syntax, an index is defined
- on the result of a user-defined function
- <replaceable class="parameter">func_name</replaceable> applied
- to one or more attributes of a single class. These functional
- indexes can be used to obtain fast access to data
- based on operators that would normally require some
- transformation to apply them to the base data.
- </para>
-
- <REFSECT2 ID="R2-SQL-CREATEINDEX-3">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <para>
+ In the second syntax, an index is defined
+ on the result of a user-defined function
+ <replaceable class="parameter">func_name</replaceable> applied
+ to one or more attributes of a single class. These functional
+ indexes can be used to obtain fast access to data
+ based on operators that would normally require some
+ transformation to apply them to the base data.
+ </para>
+
+ <refsect2 id="R2-SQL-CREATEINDEX-3">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
Currently, only the BTREE access method supports multi-column
indexes. Up to 7 keys may be specified.
- </PARA>
+ </para>
<para>
Use <command>DROP INDEX</command>
to remove an index.
</para>
- </REFSECT2>
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATEINDEX-2">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEINDEX-2">
+ <title>
Usage
- </TITLE>
- <PARA>To create a btree index on the field <literal>title</literal>
+ </title>
+ <para>To create a btree index on the field <literal>title</literal>
in the table <literal>films</literal>:
- </PARA>
- <ProgramListing>
+ </para>
+ <programlisting>
CREATE UNIQUE INDEX title_idx
ON films (title);
- </ProgramListing>
+ </programlisting>
<!--
<comment>
</programlisting>
-->
- </REFSECT1>
+ </refsect1>
- <REFSECT1 ID="R1-SQL-CREATEINDEX-3">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEINDEX-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
+ </title>
+ <para>
+ </para>
- <REFSECT2 ID="R2-SQL-CREATEINDEX-4">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEINDEX-4">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
CREATE INDEX is a <productname>Postgres</productname> language extension.
- </PARA>
+ </para>
<para>
There is no <command>CREATE INDEX</command> command in SQL92.
</para>
</refsect2>
</refsect1>
-</REFENTRY>
-
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-CREATELANGUAGE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATELANGUAGE">
+ <refmeta>
+ <refentrytitle>
CREATE LANGUAGE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE LANGUAGE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Defines a new language for functions
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-09</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-09</date>
+ </refsynopsisdivinfo>
+ <synopsis>
CREATE [ TRUSTED ] PROCEDURAL LANGUAGE '<replaceable class="parameter">langname</replaceable>'
HANDLER <replaceable class="parameter">call_handler</replaceable>
LANCOMPILER '<replaceable class="parameter">comment</replaceable>'
- </SYNOPSIS>
+ </synopsis>
- <REFSECT2 ID="R2-SQL-CREATELANGUAGE-1">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATELANGUAGE-1">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <function>TRUSTED</function>
- </TERM>
- <LISTITEM>
- <PARA>
- <function> TRUSTED</function> specifies that the call handler for
- the language is safe; that is, it offers an unprivileged user
- no functionality to bypass access restrictions. If
- this keyword is omitted when registering the language,
- only users with the <productname>Postgres</productname>
-superuser privilege can use
- this language to create new functions
- (like the 'C' language).
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
-
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">langname</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of the new procedural language.
- The language name is case insensitive. A procedural
- language cannot override one of the built-in languages of
- <productname>Postgres</productname>.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- HANDLER <replaceable class="parameter">call_handler</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- <replaceable class="parameter">call_handler</replaceable> is the name
- of a previously
- registered function that will be called to execute the PL
- procedures.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">comment</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term>TRUSTED</term>
+ <listitem>
+ <para>
+ <function> TRUSTED</function> specifies that the call handler for
+ the language is safe; that is, it offers an unprivileged user
+ no functionality to bypass access restrictions. If
+ this keyword is omitted when registering the language,
+ only users with the <productname>Postgres</productname>
+ superuser privilege can use
+ this language to create new functions
+ (like the 'C' language).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">langname</replaceable></term>
+ <listitem>
+ <para>
+ The name of the new procedural language.
+ The language name is case insensitive. A procedural
+ language cannot override one of the built-in languages of
+ <productname>Postgres</productname>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>HANDLER <replaceable class="parameter">call_handler</replaceable></term>
+ <listitem>
+ <para>
+ <replaceable class="parameter">call_handler</replaceable> is the name
+ of a previously
+ registered function that will be called to execute the PL
+ procedures.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">comment</replaceable></term>
+ <listitem>
+ <para>
The <function>LANCOMPILER</function> argument is the
string that will be
inserted in the <literal>LANCOMPILER</literal> attribute
<filename>pg_language</filename> entry. At present,
<productname>Postgres</productname> does not use
this attribute in any way.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
- </REFSECT2>
+ </refsect2>
- <REFSECT2 ID="R2-SQL-CREATELANGUAGE-2">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATELANGUAGE-2">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message is returned if the language is successfully
- created.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: PL handler function <replaceable class="parameter">funcname</replaceable>() doesn't exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message is returned if the language is successfully
+ created.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: PL handler function <replaceable class="parameter">funcname</replaceable>() doesn't exist
+ </computeroutput></term>
+ <listitem>
+ <para>
This error is returned if the function
<replaceable class="parameter">funcname</replaceable>()
is not found.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATELANGUAGE-1">
- <REFSECT1INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATELANGUAGE-1">
+ <refsect1info>
+ <date>1998-09-09</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
Using <command>CREATE LANGUAGE</command>, a
-<productname>Postgres</productname> user can register
+ <productname>Postgres</productname> user can register
a new language with <productname>Postgres</productname>.
-Subsequently, functions and
+ Subsequently, functions and
trigger procedures can be defined in this new language.
The user must have the <productname>Postgres</productname>
- superuser privilege to
+ superuser privilege to
register a new language.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-CREATELANGUAGE-3">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-CREATELANGUAGE-3">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Writing PL handlers
- </TITLE>
- <PARA>
+ </title>
+ <para>
The call handler for a procedural language must be written
in a compiler language such as 'C' and registered with
<productname>Postgres</productname> as a function taking
- no arguments and returning the
+ no arguments and returning the
<type>opaque</type> type, a placeholder for unspecified or undefined types..
This prevents the call handler from being
called directly as a function from queries.
</para>
</listitem>
</itemizedlist>
- </PARA>
+ </para>
<para>
It's up to the call handler to fetch the
<filename>pg_proc</filename> entry and
</para>
</refsect2>
- <REFSECT2 ID="R2-SQL-CREATELANGUAGE-4">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATELANGUAGE-4">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
Use <command>CREATE FUNCTION</command>
to create a function.
</para>
<para>
Refer to the table <filename>pg_language</filename>
for further information:
-<programlisting>
-<computeroutput>
+ <programlisting>
+ <computeroutput>
Table = pg_language
+--------------------------+--------------------------+-------+
| Field | Type | Length|
lisp |/usr/ucb/liszt
C |/bin/cc
sql |postgres
-</computeroutput>
-</programlisting>
+ </computeroutput>
+ </programlisting>
</para>
</refsect2>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-CREATELANGUAGE-4">
- <TITLE>
+
+ <refsect1 id="R1-SQL-CREATELANGUAGE-4">
+ <title>
Restrictions
- </TITLE>
- <PARA>
+ </title>
+ <para>
Since the call handler for a procedural language must be
registered with <productname>Postgres</productname> in the 'C' language,
- it inherits
+ it inherits
all the capabilities and restrictions of 'C' functions.
</para>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATELANGUAGE-5">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATELANGUAGE-5">
+ <title>
Bugs
- </TITLE>
- <PARA>
+ </title>
+ <para>
At present, the definitions for a procedural language cannot be
changed once they have been created.
</para>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATELANGUAGE-6">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATELANGUAGE-6">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
This is a template for a PL handler written in 'C':
- </PARA>
- <ProgramListing>
- #include "executor/spi.h"
- #include "commands/trigger.h"
- #include "utils/elog.h"
- #include "fmgr.h" /* for FmgrValues struct */
- #include "access/heapam.h"
- #include "utils/syscache.h"
- #include "catalog/pg_proc.h"
- #include "catalog/pg_type.h"
-
- Datum
- plsample_call_handler(
- Oid prooid,
- int pronargs,
- FmgrValues *proargs,
- bool *isNull)
- {
- Datum retval;
- TriggerData *trigdata;
+ <programlisting>
+#include "executor/spi.h"
+#include "commands/trigger.h"
+#include "utils/elog.h"
+#include "fmgr.h" /* for FmgrValues struct */
+#include "access/heapam.h"
+#include "utils/syscache.h"
+#include "catalog/pg_proc.h"
+#include "catalog/pg_type.h"
- if (CurrentTriggerData == NULL) {
- /*
- * Called as a function
- */
+Datum
+plsample_call_handler(
+ Oid prooid,
+ int pronargs,
+ FmgrValues *proargs,
+ bool *isNull)
+{
+ Datum retval;
+ TriggerData *trigdata;
- retval = ...
- } else {
- /*
- * Called as a trigger procedure
- */
- trigdata = CurrentTriggerData;
- CurrentTriggerData = NULL;
+ if (CurrentTriggerData == NULL) {
+ /*
+ * Called as a function
+ */
- retval = ...
- }
+ retval = ...
+ } else {
+ /*
+ * Called as a trigger procedure
+ */
+ trigdata = CurrentTriggerData;
+ CurrentTriggerData = NULL;
+
+ retval = ...
+ }
+
+ *isNull = false;
+ return retval;
+}
+ </programlisting>
+ </para>
- *isNull = false;
- return retval;
- }
- </ProgramListing>
<para>
Only a few thousand lines of code have to be added instead
of the dots to complete the PL call handler.
-See <command>CREATE FUNCTION</command> for information on how to compile
- it into a loadable module
- .</para>
+ See <command>CREATE FUNCTION</command> for information on how to compile
+ it into a loadable module.
+ </para>
<para>
The following commands then register the sample procedural
language:
<programlisting>
- CREATE FUNCTION plsample_call_handler () RETURNS opaque
+CREATE FUNCTION plsample_call_handler () RETURNS opaque
AS '/usr/local/pgsql/lib/plsample.so'
LANGUAGE 'C';
-
- CREATE PROCEDURAL LANGUAGE 'plsample'
+CREATE PROCEDURAL LANGUAGE 'plsample'
HANDLER plsample_call_handler
LANCOMPILER 'PL/Sample';
</programlisting>
</para>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-CREATELANGUAGE-7">
- <TITLE>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-CREATELANGUAGE-7">
+ <title>
Compatibility
- </TITLE>
- <PARA>
+ </title>
+ <para>
CREATE LANGUAGE is a <productname>Postgres</productname> extension.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-CREATELANGUAGE-5">
- <REFSECT2INFO>
- <DATE>1998-09-09</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-CREATELANGUAGE-5">
+ <refsect2info>
+ <date>1998-09-09</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
There is no <command>CREATE LANGUAGE</command> statement in
- <acronym>SQL92</acronym>.
- </PARA>
+ <acronym>SQL92</acronym>.
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
-
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-CREATEOPERATOR">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATEOPERATOR">
+ <refmeta>
+ <refentrytitle>
CREATE OPERATOR
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE OPERATOR
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Defines a new user operator
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1999-04-14</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1999-04-14</date>
+ </refsynopsisdivinfo>
+ <synopsis>
CREATE OPERATOR <replaceable>name</replaceable> (
PROCEDURE = <replaceable class="parameter">func_name</replaceable>
[, LEFTARG = <replaceable class="parameter">type1</replaceable> ]
[, SORT1 = <replaceable class="parameter">left_sort_op</replaceable> ]
[, SORT2 = <replaceable class="parameter">right_sort_op</replaceable> ]
)
- </SYNOPSIS>
+ </synopsis>
- <REFSECT2 ID="R2-SQL-CREATEOPERATOR-1">
- <REFSECT2INFO>
- <DATE>1999-04-14</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEOPERATOR-1">
+ <refsect2info>
+ <date>1999-04-14</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The operator to be defined. See below for allowable characters.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">func_name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The function used to implement this operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">type1</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The type for the left-hand side of the operator, if any. This option would be
-omitted for a right-unary operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">type2</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The type for the right-hand side of the operator, if any. This option would be
-omitted for a left-unary operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">com_op</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The commutator for this operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">neg_op</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The negator of this operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">res_proc</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The restriction selectivity estimator function for this operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">join_proc</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-The join selectivity estimator function for this operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-HASHES
- </TERM>
- <LISTITEM>
- <PARA>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The operator to be defined. See below for allowable characters.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">func_name</replaceable></term>
+ <listitem>
+ <para>
+ The function used to implement this operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">type1</replaceable></term>
+ <listitem>
+ <para>
+ The type for the left-hand side of the operator, if any. This option would be
+ omitted for a right-unary operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">type2</replaceable></term>
+ <listitem>
+ <para>
+ The type for the right-hand side of the operator, if any. This option would be
+ omitted for a left-unary operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">com_op</replaceable></term>
+ <listitem>
+ <para>
+ The commutator for this operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">neg_op</replaceable></term>
+ <listitem>
+ <para>
+ The negator of this operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">res_proc</replaceable></term>
+ <listitem>
+ <para>
+ The restriction selectivity estimator function for this operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">join_proc</replaceable></term>
+ <listitem>
+ <para>
+ The join selectivity estimator function for this operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>HASHES</term>
+ <listitem>
+ <para>
Indicates this operator can support a hash-join algorithm.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">left_sort_op</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-Operator that sorts the left-hand data type of this operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">right_sort_op</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-Operator that sorts the right-hand data type of this operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">left_sort_op</replaceable></term>
+ <listitem>
+ <para>
+ Operator that sorts the left-hand data type of this operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">right_sort_op</replaceable></term>
+ <listitem>
+ <para>
+ Operator that sorts the right-hand data type of this operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATEOPERATOR-2">
- <REFSECT2INFO>
- <DATE>1999-04-14</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEOPERATOR-2">
+ <refsect2info>
+ <date>1999-04-14</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
Message returned if the operator is successfully created.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATEOPERATOR-1">
- <REFSECT1INFO>
- <DATE>1999-04-14</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATEOPERATOR-1">
+ <refsect1info>
+ <date>1999-04-14</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE OPERATOR</command> defines a new operator,
<replaceable class="parameter">name</replaceable>.
The user who defines an operator becomes its owner.
is a sequence of up to thirty two (32) characters in any combination
from the following:
<literallayout>
- + - * / < > = ~ ! @ # % ^ & | ` ? $ :
++ - * / < > = ~ ! @ # % ^ & | ` ? $ :
</literallayout>
<note>
<para>
would probably have a commutator
operator, area-greater-than, >>>.
Hence, the query optimizer could freely convert:
+
<programlisting>
- "0,0,1,1"::box >>> MYBOXES.description
+"0,0,1,1"::box >>> MYBOXES.description
</programlisting>
+
to
+
<programlisting>
- MYBOXES.description <<< "0,0,1,1"::box</programlisting>
+MYBOXES.description <<< "0,0,1,1"::box
+ </programlisting>
</para>
<para>
This allows the execution code to always use the latter
equal, !==.
The negator link allows the query optimizer to simplify
<programlisting>
- NOT MYBOXES.description === "0,0,1,1"::box
+NOT MYBOXES.description === "0,0,1,1"::box
</programlisting>
to
<programlisting>
- MYBOXES.description !== "0,0,1,1"::box
+MYBOXES.description !== "0,0,1,1"::box
</programlisting>
</para>
<para>
the query optimizer can estimate result sizes. If a
clause of the form:
<programlisting>
- MYBOXES.description <<< "0,0,1,1"::box
+MYBOXES.description <<< "0,0,1,1"::box
</programlisting>
is present in the qualification,
then <productname>Postgres</productname> may have to
satisfy the clause. The function
<replaceable class="parameter">res_proc</replaceable>
must be a registered function (meaning it is already defined using
- CREATE FUNCTION) which accepts arguments of the correct
+ <command>CREATE FUNCTION</command>) which accepts arguments of the correct
data types and returns a floating point number. The
query optimizer simply calls this function, passing the
parameter "0,0,1,1" and multiplies the result by the relation
<para>
The difference between the function
<programlisting>
- my_procedure_1 (MYBOXES.description, "0,0,1,1"::box)
+my_procedure_1 (MYBOXES.description, "0,0,1,1"::box)
</programlisting>
and the operator
<programlisting>
- MYBOXES.description === "0,0,1,1"::box
+MYBOXES.description === "0,0,1,1"::box
</programlisting>
is that <productname>Postgres</productname>
attempts to optimize operators and can
optimize functions, and they are performed by brute force.
Moreover, functions can have any number of arguments while
operators are restricted to one or two.
- </PARA>
+ </para>
- <REFSECT2 ID="R2-SQL-CREATEOPERATOR-3">
- <REFSECT2INFO>
- <DATE>1999-04-14</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEOPERATOR-3">
+ <refsect2info>
+ <date>1999-04-14</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
Refer to the chapter on operators in the
<citetitle>PostgreSQL User's Guide</citetitle>
for further information.
Refer to <command>DROP OPERATOR</command> to delete
user-defined operators from a database.
</para>
- </REFSECT2>
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATEOPERATOR-2">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEOPERATOR-2">
+ <title>
Usage
- </TITLE>
- <PARA>The following command defines a new operator,
+ </title>
+ <para>The following command defines a new operator,
area-equality, for the BOX data type.
- </PARA>
- <ProgramListing>
- CREATE OPERATOR === (
+ </para>
+ <programlisting>
+CREATE OPERATOR === (
LEFTARG = box,
RIGHTARG = box,
PROCEDURE = area_equal_procedure,
JOIN = area_join_procedure,
HASHES,
SORT1 = <<<,
- SORT2 = <<<)
- </ProgramListing>
- </REFSECT1>
+ SORT2 = <<<
+);
+ </programlisting>
+ </refsect1>
- <REFSECT1 ID="R1-SQL-CREATEOPERATOR-3">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEOPERATOR-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
+ </title>
+ <para>
CREATE OPERATOR is a <productname>Postgres</productname> extension.
- </PARA>
+ </para>
- <REFSECT2 ID="R2-SQL-CREATEOPERATOR-4">
- <REFSECT2INFO>
- <DATE>1999-04-14</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEOPERATOR-4">
+ <refsect2info>
+ <date>1999-04-14</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
There is no CREATE OPERATOR statement in <acronym>SQL92</acronym>.
- </PARA>
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-CREATERULE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATERULE">
+ <refmeta>
+ <refentrytitle>
CREATE RULE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE RULE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Defines a new rule
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-11</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-CREATE RULE <replaceable class="parameter">name</replaceable>
- AS ON <replaceable class="parameter">event</replaceable>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-11</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+CREATE RULE <replaceable class="parameter">name</replaceable> AS ON <replaceable class="parameter">event</replaceable>
TO <replaceable class="parameter">object</replaceable> [ WHERE <replaceable class="parameter">condition</replaceable> ]
DO [ INSTEAD ] [ <replaceable class="parameter">action</replaceable> | NOTHING ]
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-CREATERULE-1">
- <REFSECT2INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </synopsis>
+
+ <refsect2 id="R2-SQL-CREATERULE-1">
+ <refsect2info>
+ <date>1998-09-11</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
-<replaceable class="parameter">name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a rule to create.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<replaceable class="parameter">event</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- Event is one of <literal>select</literal>,
- <literal>update</literal>, <literal>delete</literal>
- or <literal>insert</literal>.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<replaceable class="parameter">object</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- Object is either <replaceable class="parameter">table</replaceable>
- or <replaceable class="parameter">table</replaceable>.<replaceable class="parameter">column</replaceable>.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<replaceable class="parameter">condition</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- Any SQL WHERE clause. <literal>new</literal> or
- <literal>current</literal> can appear instead of an instance
- variable whenever an instance variable is permissible in SQL.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<replaceable class="parameter">action</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- Any SQL statement. <literal>new</literal> or
- <literal>current</literal> can appear instead of an instance
- variable whenever an instance variable is permissible in SQL.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
+ </title>
+ <para>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATERULE-2">
- <REFSECT2INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of a rule to create.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">event</replaceable></term>
+ <listitem>
+ <para>
+ Event is one of <literal>select</literal>,
+ <literal>update</literal>, <literal>delete</literal>
+ or <literal>insert</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">object</replaceable></term>
+ <listitem>
+ <para>
+ Object is either <replaceable class="parameter">table</replaceable>
+ or <replaceable class="parameter">table</replaceable>.<replaceable
+ class="parameter">column</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">condition</replaceable></term>
+ <listitem>
+ <para>
+ Any SQL WHERE clause. <literal>new</literal> or
+ <literal>current</literal> can appear instead of an instance
+ variable whenever an instance variable is permissible in SQL.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">action</replaceable></term>
+ <listitem>
+ <para>
+ Any SQL statement. <literal>new</literal> or
+ <literal>current</literal> can appear instead of an instance
+ variable whenever an instance variable is permissible in SQL.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CREATERULE-2">
+ <refsect2info>
+ <date>1998-09-11</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the rule is successfully created.
- </para>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the rule is successfully created.
+ </para>
</listitem>
- </VARLISTENTRY>
- </VARIABLELIST>
+ </varlistentry>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATERULE-1">
- <REFSECT1INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATERULE-1">
+ <refsect1info>
+ <date>1998-09-11</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
The semantics of a rule is that at the time an individual instance is
accessed, updated, inserted or deleted, there is a current instance (for
retrieves, updates and deletes) and a new instance (for updates and
command that caused activation.
</para>
- <REFSECT2 ID="R2-SQL-CREATERULE-3">
- <REFSECT2INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATERULE-3">
+ <refsect2info>
+ <date>1998-09-11</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
+ </title>
<para>
A caution about SQL rules is in order. If the same class name
or instance variable appears in the
variables that are shared between these clauses. For example, the following
two rules have the same semantics:
<programlisting>
-on update to EMP.salary where EMP.name = "Joe"
- do update EMP ( ... ) where ...
+ON UPDATE TO emp.salary WHERE emp.name = "Joe"
+ DO UPDATE emp ( ... ) WHERE ...
+ </programlisting>
-on update to EMP-1.salary where EMP-2.name = "Joe"
- do update EMP-3 ( ... ) where ...
+ <programlisting>
+ON UPDATE TO emp-1.salary WHERE emp-2.name = "Joe"
+ DO UPDATE emp-3 ( ... ) WHERE ...
</programlisting>
+
Each rule can have the optional tag INSTEAD.
-Without
+ Without
this tag, <replaceable class="parameter">action</replaceable> will be
performed in addition to the user command when the
<replaceable class="parameter">event</replaceable> in the
<replaceable class="parameter">action</replaceable> part will be done
instead of the user command. In this later case, the
<replaceable class="parameter">action</replaceable> can be the keyword
- NOTHING.
+ <literal>NOTHING</literal>.
</para>
<para>
When choosing between the rewrite and instance rule systems for a
It is very important to note that the rewrite rule system
will neither detect nor process circular rules. For example, though each
of the following two rule definitions are accepted by
- <productname>Postgres</productname>, the
+ <productname>Postgres</productname>, the
retrieve command will cause <productname>Postgres</productname> to crash:
<example>
<title>Example of a circular rewrite rule combination.</title>
<programlisting>
-create rule bad_rule_combination_1 as
- on select to EMP
- do instead select to TOYEMP
+CREATE RULE bad_rule_combination_1 AS
+ ON SELECT TO emp
+ DO INSTEAD SELECT TO toyemp;
+ </programlisting>
-create rule bad_rule_combination_2 as
- on select to TOYEMP
- do instead select to EMP
+ <programlisting>
+CREATE RULE bad_rule_combination_2 AS
+ ON SELECT TO toyemp
+ DO INSTEAD SELECT TO emp;
</programlisting>
- <para>
+ <para>
This attempt to retrieve from EMP will cause
- <productname>Postgres</productname> to crash.
+ <productname>Postgres</productname> to crash.
<programlisting>
-select * from EMP
+SELECT * FROM emp;
</programlisting></para>
</example>
You must have rule definition access to a class in order
to define a rule on it. Use <command>GRANT</command>
and <command>REVOKE</command> to change permissions.
-
- </PARA>
- </REFSECT2>
+ </para>
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATERULE-2">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATERULE-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Make Sam get the same salary adjustment as Joe:
<programlisting>
-create rule example_1 as
- on update EMP.salary where current.name = "Joe"
- do update EMP (salary = new.salary)
- where EMP.name = "Sam"
+CREATE RULE example_1 AS
+ ON UPDATE emp.salary WHERE current.name = "Joe"
+ DO UPDATE emp (salary = new.salary)
+ WHERE emp.name = "Sam";
</programlisting>
-
+
At the time Joe receives a salary adjustment, the event
will become true and Joe's current instance and proposed
new instance are available to the execution routines.
<para>
Make Bill get Joe's salary when it is accessed:
<programlisting>
-create rule example_2 as
- on select to EMP.salary
- where current.name = "Bill"
- do instead
- select (EMP.salary) from EMP
- where EMP.name = "Joe"
+CREATE RULE example_2 AS
+ ON SELECT TO EMP.salary
+ WHERE current.name = "Bill"
+ DO INSTEAD
+ SELECT (emp.salary) from emp
+ WHERE emp.name = "Joe";
</programlisting>
</para>
<para>
department (<function>current_user</function> returns the name of
the current user):
<programlisting>
-create rule example_3 as
- on select to EMP.salary
- where current.dept = "shoe" and current_user = "Joe"
- do instead nothing
+CREATE RULE example_3 AS
+ ON SELECT TO emp.salary
+ WHERE current.dept = "shoe" AND current_user = "Joe"
+ DO INSTEAD NOTHING;
</programlisting>
</para>
<para>
Create a view of the employees working in the toy department.
<programlisting>
-create TOYEMP(name = char16, salary = int4)
+CREATE toyemp(name = char16, salary = int4);
-create rule example_4 as
- on select to TOYEMP
- do instead
- select (EMP.name, EMP.salary) from EMP
- where EMP.dept = "toy"
+CREATE RULE example_4 AS
+ ON SELECT TO toyemp
+ DO INSTEAD
+ SELECT (emp.name, emp.salary) FROM emp
+ WHERE emp.dept = "toy";
</programlisting>
</para>
<para>
All new employees must make 5,000 or less
<programlisting>
-create rule example_5 as
- on insert to EMP where new.salary > 5000
- do update newset salary = 5000
+CREATE RULE example_5 AS
+ ON INERT TO emp WHERE new.salary > 5000
+ DO UPDATE NEWSET salary = 5000;
</programlisting>
- </PARA>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-CREATERULE-3">
- <TITLE>
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-CREATERULE-3">
+ <title>
Bugs
- </TITLE>
+ </title>
<para>
- The object in a SQL rule cannot be an array reference and
+ The object in a <acronym>SQL</acronym> rule cannot be an array reference and
cannot have parameters.
</para>
<para>
text attributes. This implies that creation of rules may
fail if the rule plus its various internal representations
exceed some value that is on the order of one page (8KB).
- </PARA>
+ </para>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-CREATERULE-4">
- <TITLE>
+
+ <refsect1 id="R1-SQL-CREATERULE-4">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- CREATE RULE statement is a <productname>Postgres</productname>
- language extension.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-CREATERULE-4">
- <REFSECT2INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ <command>CREATE RULE</command> statement is a <productname>Postgres</productname>
+ language extension.
+ </para>
+
+ <refsect2 id="R2-SQL-CREATERULE-4">
+ <refsect2info>
+ <date>1998-09-11</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
+ </title>
<para>
- There is no CREATE RULE statement in <acronym>SQL92</acronym>.
+ There is no <command>CREATE RULE</command> statement in <acronym>SQL92</acronym>.
</para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-CREATESEQUENCE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATESEQUENCE">
+ <refmeta>
+ <refentrytitle>
CREATE SEQUENCE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE SEQUENCE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Creates a new sequence number generator
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
CREATE SEQUENCE <replaceable class="parameter">seqname</replaceable>
[ INCREMENT <replaceable class="parameter">increment</replaceable> ]
[ MINVALUE <replaceable class="parameter">minvalue</replaceable> ]
[ START <replaceable class="parameter">start</replaceable> ]
[ CACHE <replaceable class="parameter">cache</replaceable> ]
[ CYCLE ]
- </SYNOPSIS>
+ </synopsis>
- <REFSECT2 ID="R2-SQL-CREATESEQUENCE-1">
- <REFSECT2INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATESEQUENCE-1">
+ <refsect2info>
+ <date>1998-09-11</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">seqname</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a sequence to be created.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">increment</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The <option>INCREMENT <replaceable class="parameter">increment</replaceable></option> clause is optional. A positive value will make an
- ascending sequence, a negative one a descending sequence.
- The default value is one (1).
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">minvalue</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The optional clause <option>MINVALUE
- <replaceable class="parameter">minvalue</replaceable></option>
- determines the minimum value
- a sequence can generate. The defaults are 1 and -2147483647 for
- ascending and descending sequences, respectively.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">maxvalue</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- Use the optional clause <option>MAXVALUE
- <replaceable class="parameter">maxvalue</replaceable></option> to
- determine the maximum
- value for the sequence. The defaults are 2147483647 and -1 for
- ascending and descending sequences, respectively.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">seqname</replaceable></term>
+ <listitem>
+ <para>
+ The name of a sequence to be created.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">increment</replaceable></term>
+ <listitem>
+ <para>
+ The
+ <option>INCREMENT <replaceable class="parameter">increment</replaceable></option>
+ clause is optional. A positive value will make an
+ ascending sequence, a negative one a descending sequence.
+ The default value is one (1).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">minvalue</replaceable></term>
+ <listitem>
+ <para>
+ The optional clause <option>MINVALUE
+ <replaceable class="parameter">minvalue</replaceable></option>
+ determines the minimum value
+ a sequence can generate. The defaults are 1 and -2147483647 for
+ ascending and descending sequences, respectively.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">maxvalue</replaceable></term>
+ <listitem>
+ <para>
+ Use the optional clause <option>MAXVALUE
+ <replaceable class="parameter">maxvalue</replaceable></option> to
+ determine the maximum
+ value for the sequence. The defaults are 2147483647 and -1 for
+ ascending and descending sequences, respectively.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">start</replaceable></term>
+ <listitem>
+ <para>
+ The optional <option>START
<replaceable class="parameter">start</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The optional <option>START
- <replaceable class="parameter">start</replaceable>
- clause</option> enables the sequence to begin anywhere.
- The default starting value is
- <replaceable class="parameter">minvalue</replaceable>
- for ascending sequences and
- <replaceable class="parameter">maxvalue</replaceable>
- for descending ones.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">cache</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The <option>CACHE <replaceable class="parameter">cache</replaceable></option> option
- enables sequence numbers to be preallocated
- and stored in memory for faster access. The minimum
- value is 1 (only one value can be generated at a time, i.e. no cache)
- and this is also the default.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- CYCLE
- </TERM>
- <LISTITEM>
- <PARA>
- The optional CYCLE keyword may be used to enable the sequence
- to continue when the
- <replaceable class="parameter">maxvalue</replaceable> or
- <replaceable class="parameter">minvalue</replaceable> has been
- reached by
- an ascending or descending sequence respectively. If the limit is
- reached, the next number generated will be whatever the
- <replaceable class="parameter">minvalue</replaceable> or
- <replaceable class="parameter">maxvalue</replaceable> is,
- as appropriate.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATESEQUENCE-2">
- <REFSECT2INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT2INFO>
- <TITLE>
+ clause</option> enables the sequence to begin anywhere.
+ The default starting value is
+ <replaceable class="parameter">minvalue</replaceable>
+ for ascending sequences and
+ <replaceable class="parameter">maxvalue</replaceable>
+ for descending ones.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">cache</replaceable></term>
+ <listitem>
+ <para>
+ The <option>CACHE <replaceable class="parameter">cache</replaceable></option> option
+ enables sequence numbers to be preallocated
+ and stored in memory for faster access. The minimum
+ value is 1 (only one value can be generated at a time, i.e. no cache)
+ and this is also the default.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>CYCLE</term>
+ <listitem>
+ <para>
+ The optional CYCLE keyword may be used to enable the sequence
+ to continue when the
+ <replaceable class="parameter">maxvalue</replaceable> or
+ <replaceable class="parameter">minvalue</replaceable> has been
+ reached by
+ an ascending or descending sequence respectively. If the limit is
+ reached, the next number generated will be whatever the
+ <replaceable class="parameter">minvalue</replaceable> or
+ <replaceable class="parameter">maxvalue</replaceable> is,
+ as appropriate.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CREATESEQUENCE-2">
+ <refsect2info>
+ <date>1998-09-11</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the command is successful.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<ReturnValue>ERROR: amcreate: '<replaceable class="parameter">seqname</replaceable>' relation already exists</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- If the sequence specified already exists.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<ReturnValue>ERROR: DefineSequence: START value (<replaceable class="parameter">start</replaceable>) can't be > MAXVALUE (<replaceable class="parameter">maxvalue</replaceable>)</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- If the specified starting value is out of range.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<ReturnValue>ERROR: DefineSequence: START value (<replaceable class="parameter">start</replaceable>) can't be < MINVALUE (<replaceable class="parameter">minvalue</replaceable>)</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- If the specified starting value is out of range.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-<ReturnValue>ERROR: DefineSequence: MINVALUE (<replaceable class="parameter">minvalue</replaceable>) can't be >= MAXVALUE (<replaceable class="parameter">maxvalue</replaceable>)</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- If the minimum and maximum values are inconsistant.
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the command is successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: Relation '<replaceable class="parameter">seqname</replaceable>' already exists
+ </computeroutput></term>
+ <listitem>
+ <para>
+ If the sequence specified already exists.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: DefineSequence: MINVALUE (<replaceable class="parameter">start</replaceable>) can't be >= MAXVALUE (<replaceable class="parameter">max</replaceable>)
+ </computeroutput></term>
+ <listitem>
+ <para>
+ If the specified starting value is out of range.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: DefineSequence: START value (<replaceable class="parameter">start</replaceable>) can't be < MINVALUE (<replaceable class="parameter">min</replaceable>)
+ </computeroutput></term>
+ <listitem>
+ <para>
+ If the specified starting value is out of range.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: DefineSequence: MINVALUE (<replaceable class="parameter">min</replaceable>) can't be >= MAXVALUE (<replaceable class="parameter">max</replaceable>)
+ </computeroutput></term>
+ <listitem>
+ <para>
+ If the minimum and maximum values are inconsistant.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATESEQUENCE-1">
- <REFSECT1INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATESEQUENCE-1">
+ <refsect1info>
+ <date>1998-09-11</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
- CREATE SEQUENCE will enter a new sequence number generator
+ </title>
+ <para>
+ <command>CREATE SEQUENCE</command> will enter a new sequence number generator
into the current data base. This involves creating and initialising a
new single-row
table with the name <replaceable class="parameter">seqname</replaceable>.
The generator will be "owned" by the user issuing the command.
- </PARA>
+ </para>
<para>
After a sequence is created, you may use the function
-<function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
-to get a new number from the sequence.
-The function
-<function>currval('<replaceable class="parameter">seqname</replaceable>')</function>
- may be used to determine the number returned by the last call to
-<function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
- for the specified sequence in the current session.
-The function
-<function>setval('<replaceable class="parameter">seqname</replaceable>',
- <replaceable class="parameter">newvalue</replaceable>)</function>
-may be used to set the current value of the specified sequence.
-The next call to
-<function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
-will return the given value plus the sequence increment.
+ <function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
+ to get a new number from the sequence.
+ The function
+ <function>currval('<replaceable class="parameter">seqname</replaceable>')</function>
+ may be used to determine the number returned by the last call to
+ <function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
+ for the specified sequence in the current session.
+ The function
+ <function>setval('<replaceable class="parameter">seqname</replaceable>',
+ <replaceable class="parameter">newvalue</replaceable>)</function>
+ may be used to set the current value of the specified sequence.
+ The next call to
+ <function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
+ will return the given value plus the sequence increment.
</para>
-
+
<para>
Use a query like
<programlisting>
calls to a generator.
</para>
-<caution>
+ <caution>
<para>
Unexpected results may be obtained if a cache setting greater than one
is used for a sequence object that will be used concurrently by multiple
whether or not it has yet been returned by nextval.
</para>
</caution>
-
- <REFSECT2 ID="R2-SQL-CREATESEQUENCE-3">
- <REFSECT2INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT2INFO>
- <TITLE>
+
+ <refsect2 id="R2-SQL-CREATESEQUENCE-3">
+ <refsect2info>
+ <date>1998-09-11</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
- Refer to the DROP SEQUENCE statement to remove a sequence.
- </PARA>
+ </title>
+ <para>
+ Refer to the <command>DROP SEQUENCE</command> statement to remove a sequence.
+ </para>
<para>
Each backend uses its own cache to store allocated numbers.
Numbers that are cached but not used in the current session will be
lost, resulting in "holes" in the sequence.
</para>
- </REFSECT2>
+ </refsect2>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-CREATESEQUENCE-2">
- <TITLE>
+
+ <refsect1 id="R1-SQL-CREATESEQUENCE-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Create an ascending sequence called <literal>serial</literal>, starting at 101:
- </PARA>
- <ProgramListing>
+ </para>
+ <programlisting>
CREATE SEQUENCE serial START 101;
- </ProgramListing>
+ </programlisting>
<para>
Select the next number from this sequence
<programlisting>
<para>
Set the sequence value after a COPY FROM:
<programlisting>
- CREATE FUNCTION distributors_id_max() RETURNS INT4
+CREATE FUNCTION distributors_id_max() RETURNS INT4
AS 'SELECT max(id) FROM distributors'
LANGUAGE 'sql';
- BEGIN;
+BEGIN;
COPY distributors FROM 'input_file';
SELECT setval('serial', distributors_id_max());
- END;
+END;
</programlisting>
</para>
-
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-CREATESEQUENCE-3">
- <TITLE>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-CREATESEQUENCE-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE SEQUENCE</command> is a <productname>Postgres</productname>
language extension.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-CREATESEQUENCE-4">
- <REFSECT2INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-CREATESEQUENCE-4">
+ <refsect2info>
+ <date>1998-09-11</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
There is no <command>CREATE SEQUENCE</command> statement
- in <acronym>SQL92</acronym>.
- </PARA>
+ in <acronym>SQL92</acronym>.
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
-
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
</refsynopsisdivinfo>
<synopsis>
CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replaceable> (
- <replaceable class="PARAMETER">column</replaceable> <replaceable
- class="PARAMETER">type</replaceable>
- [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <replaceable
- class="PARAMETER">value</replaceable> ]
+ <replaceable class="PARAMETER">column</replaceable> <replaceable class="PARAMETER">type</replaceable>
+ [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <replaceable class="PARAMETER">value</replaceable> ]
[<replaceable>column_constraint_clause</replaceable> | PRIMARY KEY } [ ... ] ]
[, ... ]
[, PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) ]
</title>
<para>
-
- <variablelist>
- <varlistentry>
- <term>
- TEMPORARY
- </term>
- <listitem>
- <para>
+
+ <variablelist>
+ <varlistentry>
+ <term>TEMPORARY</term>
+ <listitem>
+ <para>
The table is created only for this session, and is
automatically dropped on session exit.
Existing permanent tables with the same name are not visible
while the temporary table exists.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="PARAMETER">table</replaceable>
- </term>
- <listitem>
- <para>
- The name of a new table to be created.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="PARAMETER">column</replaceable>
- </term>
- <listitem>
- <para>
- The name of a column.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="PARAMETER">type</replaceable>
- </term>
- <listitem>
- <para>
- The type of the column. This may include array specifiers.
- Refer to the <citetitle>PostgreSQL User's Guide</citetitle> for
- further information about data types and arrays.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- DEFAULT <replaceable class="PARAMETER">value</replaceable>
- </term>
- <listitem>
- <para>
- A default value for a column.
- See the DEFAULT clause for more information.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable>column_constraint_clause</replaceable>
- </term>
- <listitem>
- <para>
- The optional column constraint clauses specify a list of integrity
- constraints or tests which new or updated entries must satisfy for
- an insert or update operation to succeed. Each constraint
- must evaluate to a boolean expression. Although <acronym>SQL92</acronym>
-requires the <replaceable class="PARAMETER">column_constraint_clause</replaceable>
- to refer to that column only, <productname>Postgres</productname>
- allows multiple columns
- to be referenced within a single column constraint.
- See the column constraint clause for more information.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable>table_constraint_clause</replaceable>
- </term>
- <listitem>
- <para>
- The optional table CONSTRAINT clause specifies a list of integrity
- constraints which new or updated entries must satisfy for
- an insert or update operation to succeed. Each constraint
- must evaluate to a boolean expression. Multiple columns
- may be referenced within a single constraint.
- Only one PRIMARY KEY clause may be specified for a table;
- PRIMARY KEY <replaceable>column</replaceable>
- (a table constraint) and PRIMARY KEY (a column constraint) are
- mutually exclusive..
- See the table constraint clause for more information.
- </para>
- </listitem>
- </varlistentry>
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
- <term>
- INHERITS <replaceable class="PARAMETER">inherited_table</replaceable>
- </term>
+ <term><replaceable class="PARAMETER">table</replaceable></term>
+ <listitem>
+ <para>
+ The name of a new table to be created.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="PARAMETER">column</replaceable></term>
+ <listitem>
+ <para>
+ The name of a column.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="PARAMETER">type</replaceable></term>
+ <listitem>
+ <para>
+ The type of the column. This may include array specifiers.
+ Refer to the <citetitle>PostgreSQL User's Guide</citetitle> for
+ further information about data types and arrays.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>DEFAULT <replaceable class="PARAMETER">value</replaceable></term>
+ <listitem>
+ <para>
+ A default value for a column.
+ See the DEFAULT clause for more information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable>column_constraint_clause</replaceable></term>
+ <listitem>
+ <para>
+ The optional column constraint clauses specify a list of integrity
+ constraints or tests which new or updated entries must satisfy for
+ an insert or update operation to succeed. Each constraint
+ must evaluate to a boolean expression. Although <acronym>SQL92</acronym>
+ requires the <replaceable class="PARAMETER">column_constraint_clause</replaceable>
+ to refer to that column only, <productname>Postgres</productname>
+ allows multiple columns
+ to be referenced within a single column constraint.
+ See the column constraint clause for more information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable>table_constraint_clause</replaceable></term>
+ <listitem>
+ <para>
+ The optional table CONSTRAINT clause specifies a list of integrity
+ constraints which new or updated entries must satisfy for
+ an insert or update operation to succeed. Each constraint
+ must evaluate to a boolean expression. Multiple columns
+ may be referenced within a single constraint.
+ Only one PRIMARY KEY clause may be specified for a table;
+ PRIMARY KEY <replaceable>column</replaceable>
+ (a table constraint) and PRIMARY KEY (a column constraint) are
+ mutually exclusive..
+ See the table constraint clause for more information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>INHERITS <replaceable class="PARAMETER">inherited_table</replaceable></term>
<listitem>
<para>
The optional INHERITS clause specifies a collection of table
</variablelist>
</para>
</refsect2>
-
+
<refsect2 id="R2-SQL-CREATETABLE-2">
<refsect2info>
<date>1998-09-11</date>
</title>
<para>
- <variablelist>
- <varlistentry>
- <term>
- <returnvalue>CREATE</returnvalue>
- </term>
- <listitem>
- <para>
- Message returned if table is successfully created.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <returnvalue>ERROR</returnvalue>
- </term>
- <listitem>
- <para>
- Message returned if table creation failed.
- This is usually accompanied by some descriptive text, such as:
- <programlisting>
-amcreate: "<replaceable class="parameter">table</replaceable>" relation already exists
- </programlisting>
- which occurs at runtime, if the table specified already exists
- in the database.
- </para>
- </listitem>
- </varlistentry>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if table is successfully created.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- <returnvalue>ERROR: DEFAULT: type mismatched</returnvalue>
- </term>
- <listitem>
- <para>
- if data type of default value doesn't match the
- column definition's data type.
+ <varlistentry>
+ <term><computeroutput>
+ERROR
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if table creation failed.
+ This is usually accompanied by some descriptive text, such as:
+ <computeroutput>
+ERROR: Relation '<replaceable class="parameter">table</replaceable>' already exists
+ </computeroutput>
+ which occurs at runtime, if the table specified already exists
+ in the database.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+ERROR: DEFAULT: type mismatched
+ </computeroutput></term>
+ <listitem>
+ <para>
+ If data type of default value doesn't match the
+ column definition's data type.
</para>
</listitem>
</varlistentry>
</para>
</refsect2>
</refsynopsisdiv>
-
+
<refsect1 id="R1-SQL-CREATETABLE-1">
<refsect1info>
<date>1998-09-11</date>
</refsect1>
<refsect1 id="R1-SQL-DEFAULTCLAUSE-1">
- <refsect1info>
- <date>1998-09-11</date>
- </refsect1info>
- <title>
- DEFAULT Clause
- </title>
- <para>
- <synopsis>
+ <refsect1info>
+ <date>1998-09-11</date>
+ </refsect1info>
+ <title>
+ DEFAULT Clause
+ </title>
+ <para>
+ <synopsis>
DEFAULT <replaceable class="PARAMETER">value</replaceable>
- </synopsis>
+ </synopsis>
</para>
<refsect2 id="R2-SQL-DEFAULTCLAUSE-1">
<refsect2info>
<date>1998-09-11</date>
</refsect2info>
<title>
- Inputs
- </title>
- <para>
- <variablelist>
- <varlistentry>
- <term>
- <replaceable class="parameter">value</replaceable>
- </term>
+ Inputs
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">value</replaceable></term>
+ <listitem>
+ <para>
+ The possible values for the default value expression are:
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ a literal value
+ </simpara>
+ </listitem>
<listitem>
- <para>
- The possible values for the default value expression are:
- <itemizedlist>
- <listitem>
- <simpara>
- a literal value
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- a user function
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- a niladic function
+ <simpara>
+ a user function
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ a niladic function
</simpara>
</listitem>
</itemizedlist>
Outputs
</title>
<para>
+ None.
</para>
</refsect2>
<date>1998-09-11</date>
</refsect2info>
<title>
- Description
- </title>
- <para>
- The DEFAULT clause assigns a default data value to a column
- (via a column definition in the CREATE TABLE statement).
- The data type of a default value must match the column definition's
- data type.
- </para>
- <para>
- An INSERT operation that includes a column without a specified
- default value will assign the NULL value to the column
- if no explicit data value is provided for it.
- Default <replaceable class="parameter">literal</replaceable> means
- that the default is the specified constant value.
- Default <replaceable class="parameter">niladic-function</replaceable>
- or <replaceable class="parameter">user-function</replaceable> means
- that the default
- is the value of the specified function at the time of the INSERT.
- </para>
- <para>
- There are two types of niladic functions:
-<variablelist>
+ Description
+ </title>
+ <para>
+ The DEFAULT clause assigns a default data value to a column
+ (via a column definition in the CREATE TABLE statement).
+ The data type of a default value must match the column definition's
+ data type.
+ </para>
+ <para>
+ An INSERT operation that includes a column without a specified
+ default value will assign the NULL value to the column
+ if no explicit data value is provided for it.
+ Default <replaceable class="parameter">literal</replaceable> means
+ that the default is the specified constant value.
+ Default <replaceable class="parameter">niladic-function</replaceable>
+ or <replaceable class="parameter">user-function</replaceable> means
+ that the default
+ is the value of the specified function at the time of the INSERT.
+ </para>
+ <para>
+ There are two types of niladic functions:
+ <variablelist>
+ <varlistentry>
+ <term>niladic USER</term>
+ <listitem>
+ <variablelist>
+ <varlistentry>
+ <term>CURRENT_USER / USER</term>
+ <listitem>
+ <simpara>See CURRENT_USER function</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>SESSION_USER</term>
+ <listitem>
+ <simpara>not yet supported</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>SYSTEM_USER</term>
+ <listitem>
+ <simpara>not yet supported</simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>niladic datetime</term>
+ <listitem>
+ <variablelist>
+ <varlistentry>
+ <term>CURRENT_DATE</term>
+ <listitem>
+ <simpara>See CURRENT_DATE function</simpara>
+ </listitem>
+ </varlistentry>
<varlistentry>
- <term>niladic USER</term>
+ <term>CURRENT_TIME</term>
<listitem>
- <variablelist>
- <varlistentry>
- <term>CURRENT_USER / USER</term>
- <listitem>
- <simpara>See CURRENT_USER function</simpara>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>SESSION_USER</term>
- <listitem>
- <simpara>not yet supported</simpara>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>SYSTEM_USER</term>
- <listitem>
- <simpara>not yet supported</simpara>
- </listitem>
- </varlistentry>
- </variablelist>
+ <simpara>See CURRENT_TIME function</simpara>
</listitem>
</varlistentry>
<varlistentry>
- <term>niladic datetime</term>
+ <term>CURRENT_TIMESTAMP</term>
<listitem>
- <variablelist>
- <varlistentry>
- <term> CURRENT_DATE</term>
- <listitem>
- <simpara>See CURRENT_DATE function</simpara>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>CURRENT_TIME</term>
- <listitem>
- <simpara>See CURRENT_TIME function</simpara>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>CURRENT_TIMESTAMP</term>
- <listitem>
- <simpara>See CURRENT_TIMESTAMP function</simpara>
- </listitem>
- </varlistentry>
- </variablelist>
+ <simpara>See CURRENT_TIMESTAMP function</simpara>
</listitem>
</varlistentry>
</variablelist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
-<para>
-In the current release (v6.5), <productname>Postgres</productname>
-evaluates all default expressions at the time the table is defined.
-Hence, functions which are "non-cacheable" such as
- <function>CURRENT_TIMESTAMP</function> may not produce the desired
-effect. For the particular case of date/time types, one can work
-around this behavior by using
-<quote>
-DEFAULT TEXT 'now'
-</quote>
-instead of
-<quote>
-DEFAULT 'now'
-</quote>
-or
-<quote>
-DEFAULT CURRENT_TIMESTAMP
-</quote>.
-This forces <productname>Postgres</productname> to consider the constant a string
-type and then to convert the value to <type>timestamp</type> at runtime.
+ <para>
+ In the current release (v6.5), <productname>Postgres</productname>
+ evaluates all default expressions at the time the table is defined.
+ Hence, functions which are "non-cacheable" such as
+ <function>CURRENT_TIMESTAMP</function> may not produce the desired
+ effect. For the particular case of date/time types, one can work
+ around this behavior by using
+ <quote>DEFAULT TEXT 'now'</quote>
+ instead of
+ <quote>DEFAULT 'now'</quote>
+ or
+ <quote>DEFAULT CURRENT_TIMESTAMP</quote>.
+ This forces <productname>Postgres</productname> to consider the constant a string
+ type and then to convert the value to <type>timestamp</type> at runtime.
</para>
</refsect2>
<refsect2 id="R2-SQL-DEFAULTCLAUSE-4">
<date>1998-09-11</date>
</refsect2info>
<title>
- Usage
+ Usage
</title>
+
<para>
- To assign a constant value as the default for the
- columns <literal>did</literal> and <literal>number</literal>,
- and a string literal to the column <literal>did</literal>:
-
- <programlisting>
+ To assign a constant value as the default for the
+ columns <literal>did</literal> and <literal>number</literal>,
+ and a string literal to the column <literal>did</literal>:
+
+ <programlisting>
CREATE TABLE video_sales (
did VARCHAR(40) DEFAULT 'luso films',
number INTEGER DEFAULT 0,
total CASH DEFAULT '$0.0'
);
- </programlisting>
+ </programlisting>
</para>
<para>
- To assign an existing sequence
- as the default for the column <literal>did</literal>,
- and a literal to the column <literal>name</literal>:
-
- <programlisting>
+ To assign an existing sequence
+ as the default for the column <literal>did</literal>,
+ and a literal to the column <literal>name</literal>:
+
+ <programlisting>
CREATE TABLE distributors (
did DECIMAL(3) DEFAULT NEXTVAL('serial'),
name VARCHAR(40) DEFAULT 'luso films'
);
- </programlisting>
+ </programlisting>
</para>
</refsect2>
- </refsect1>
-
- <refsect1 id="R1-SQL-COLUMNCONSTRAINT-1">
- <refsect1info>
- <date>1998-09-11</date>
- </refsect1info>
- <title>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-COLUMNCONSTRAINT-1">
+ <refsect1info>
+ <date>1998-09-11</date>
+ </refsect1info>
+ <title>
Column CONSTRAINT Clause
- </title>
- <para>
+ </title>
+ <para>
<synopsis>
[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] { [
NULL | NOT NULL ] | UNIQUE | PRIMARY KEY | CHECK <replaceable
Inputs
</title>
<para>
- <variablelist>
- <varlistentry>
- <term>
- <replaceable class="parameter">name</replaceable>
- </term>
- <listitem>
- <para>
- An arbitrary name given to the integrity constraint.
-If <replaceable class="parameter">name</replaceable> is not specified,
- it is generated from the table and column names,
-which should ensure uniqueness for
- <replaceable class="parameter">name</replaceable>.
- </para>
- </listitem>
- </varlistentry>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ An arbitrary name given to the integrity constraint.
+ If <replaceable class="parameter">name</replaceable> is not specified,
+ it is generated from the table and column names,
+ which should ensure uniqueness for
+ <replaceable class="parameter">name</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- NULL
- </term>
- <listitem>
- <para>
-The column is allowed to contain NULL values. This is the default.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- NOT NULL
- </term>
- <listitem>
- <para>
-The column is not allowed to contain NULL values.
-This is equivalent to the column constraint
- CHECK (<replaceable class="PARAMETER">column</replaceable> NOT NULL).
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- UNIQUE
- </term>
- <listitem>
- <para>
-The column must have unique values. In <productname>Postgres</productname>
-this is enforced by an implicit creation of a unique index on the table.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- PRIMARY KEY
- </term>
- <listitem>
- <para>
- This column is a primary key, which implies that uniqueness is
-enforced by the system and that other tables may rely on this column
-as a unique identifier for rows.
- See PRIMARY KEY for more information.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="parameter">constraint</replaceable>
- </term>
- <listitem>
- <para>
- The definition of the constraint.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </para>
+ <varlistentry>
+ <term>NULL</term>
+ <listitem>
+ <para>
+ The column is allowed to contain NULL values. This is the default.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>NOT NULL</term>
+ <listitem>
+ <para>
+ The column is not allowed to contain NULL values.
+ This is equivalent to the column constraint
+ CHECK (<replaceable class="PARAMETER">column</replaceable> NOT NULL).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>UNIQUE</term>
+ <listitem>
+ <para>
+ The column must have unique values. In <productname>Postgres</productname>
+ this is enforced by an implicit creation of a unique index on the table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>PRIMARY KEY</term>
+ <listitem>
+ <para>
+ This column is a primary key, which implies that uniqueness is
+ enforced by the system and that other tables may rely on this column
+ as a unique identifier for rows.
+ See PRIMARY KEY for more information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+<replaceable class="parameter">constraint</replaceable>
+ </term>
+ <listitem>
+ <para>
+ The definition of the constraint.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</refsect2>
<refsect2 id="R2-SQL-COLUMNCONSTRAINT-2">
Outputs
</title>
<para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable>status</replaceable></term>
+ <listitem>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: ExecAppend: Fail to add null value in not null attribute "<replaceable class="parameter">column</replaceable>".
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This error occurs at runtime if one tries to insert a null value
+ into a column which has a NOT NULL constraint.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
- <variablelist>
- <varlistentry>
- <term>
- <replaceable>status</replaceable>
- </term>
- <listitem>
- <para>
- <variablelist>
- <varlistentry>
- <term>
- <returnvalue>ERROR: ExecAppend: Fail to add null value in not
- null attribute "<replaceable class="parameter">column</replaceable>".</returnvalue>
- </term>
- <listitem>
- <para>
- This error occurs at runtime if one tries to insert a null value
- into a column which has a NOT NULL constraint.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
</refsect3>
<refsect3 id="R3-SQL-NOTNULL-2">
<para>
</para>
</refsect3>
-
+
<refsect3 id="R3-SQL-NOTNULL-3">
<refsect3info>
<date>1998-09-11</date>
<title>
Usage
</title>
-
+
<para>
Define two NOT NULL column constraints on the table
<classname>distributors</classname>,
one of which being a named constraint:
-
- <programlisting>
- CREATE TABLE distributors (
- did DECIMAL(3) CONSTRAINT no_null NOT NULL,
- name VARCHAR(40) NOT NULL
- );
+
+ <programlisting>
+CREATE TABLE distributors (
+ did DECIMAL(3) CONSTRAINT no_null NOT NULL,
+ name VARCHAR(40) NOT NULL
+);
</programlisting>
</para>
</refsect3>
</refsect2>
-
+
<refsect2 id="R2-SQL-UNIQUECLAUSE-1">
<refsect2info>
<date>1998-09-11</date>
<refsect3>
<title>Inputs</title>
<para>
+
<variablelist>
<varlistentry>
- <term>
- CONSTRAINT <replaceable class="parameter">name</replaceable>
- </term>
+ <term>CONSTRAINT <replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
An arbitrary label given to a constraint.
<refsect3>
<title>Outputs</title>
<para>
- <variablelist>
- <varlistentry>
- <term>
-<replaceable>status</replaceable>
- </term>
- <listitem>
- <para>
- <variablelist>
- <varlistentry>
- <term>
-<returnvalue>ERROR: Cannot insert a duplicate key into a unique index.</returnvalue>
- </term>
- <listitem>
- <para>
- This error occurs at runtime if one tries to insert a
- duplicate value into a column.
+ <variablelist>
+ <varlistentry>
+ <term><replaceable>status</replaceable></term>
+ <listitem>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: Cannot insert a duplicate key into a unique index.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This error occurs at runtime if one tries to insert a
+ duplicate value into a column.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect3>
-
+
<refsect3>
<title>
-Description
+ Description
</title>
<para>
include a NOT NULL constraint to be included in a UNIQUE
constraint. Having more than one null value in a column without a
NOT NULL constraint, does not violate a UNIQUE constraint.
-(This deviates from the <acronym>SQL92</acronym> definition, but
-is a more sensible convention. See the section on compatibility
-for more details.).
+ (This deviates from the <acronym>SQL92</acronym> definition, but
+ is a more sensible convention. See the section on compatibility
+ for more details.).
</para>
<para>
Each UNIQUE column constraint must name a column that is
<note>
<para>
<productname>Postgres</productname> automatically creates a unique
- index for each UNIQUE constraint, to assure
+ index for each UNIQUE constraint, to assure
data integrity. See CREATE INDEX for more information.
</para>
</note>
</refsect3>
- <refsect3 id="R3-SQL-UNIQUECLAUSE-3">
- <title>
-Usage
-</title>
+ <refsect3 id="R3-SQL-UNIQUECLAUSE-3">
+ <title>
+ Usage
+ </title>
- <para>
- Defines a UNIQUE column constraint for the table distributors.
- UNIQUE column constraints can only be defined on one column
- of the table:
- <programlisting>
- CREATE TABLE distributors (
- did DECIMAL(3),
- name VARCHAR(40) UNIQUE
- );
+ <para>
+ Defines a UNIQUE column constraint for the table distributors.
+ UNIQUE column constraints can only be defined on one column
+ of the table:
+ <programlisting>
+CREATE TABLE distributors (
+ did DECIMAL(3),
+ name VARCHAR(40) UNIQUE
+);
</programlisting>
-which is equivalent to the following specified as a table constraint:
- <programlisting>
+
+ which is equivalent to the following specified as a table constraint:
+ <programlisting>
CREATE TABLE distributors (
did DECIMAL(3),
name VARCHAR(40),
UNIQUE(name)
);
- </programlisting>
+ </programlisting>
</para>
</refsect3>
</refsect2>
-
+
<refsect2 id="R2-SQL-CHECK-1">
<refsect2info>
<date>1998-09-11</date>
</refsect2info>
-<title>
-The CHECK Constraint
-</title>
- <synopsis>
+ <title>
+ The CHECK Constraint
+ </title>
+ <synopsis>
[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] CHECK
( <replaceable>condition</replaceable> [, ...] )
- </synopsis>
+ </synopsis>
<refsect3 id="R3-SQL-CHECK-1">
<title>Inputs</title>
- <para>
- <variablelist>
- <varlistentry>
- <term>
- <returnvalue><replaceable class="parameter">name</replaceable></returnvalue>
- </term>
- <listitem>
- <para>
- An arbitrary name given to a constraint.
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ An arbitrary name given to a constraint.
</para>
</listitem>
</varlistentry>
<varlistentry>
- <term>
- <replaceable>condition</replaceable>
- </term>
+ <term><replaceable>condition</replaceable></term>
<listitem>
<para>
Any valid conditional expression evaluating to a boolean result.
</variablelist>
</para>
</refsect3>
-
+
<refsect3 id="R3-SQL-CHECK-2">
<refsect3info>
<date>1998-09-11</date>
Outputs
</title>
<para>
+
<variablelist>
<varlistentry>
- <term>
- <replaceable>status</replaceable>
- </term>
+ <term><replaceable>status</replaceable></term>
<listitem>
<para>
-
+
<variablelist>
<varlistentry>
- <term>
- <returnvalue>
- ERROR: ExecAppend: rejected due to CHECK constraint
- "<replaceable class="parameter">table_column</replaceable>".
- </returnvalue>
- </term>
+ <term><computeroutput>
+ERROR: ExecAppend: rejected due to CHECK constraint "<replaceable class="parameter">table_column</replaceable>".
+ </computeroutput></term>
<listitem>
<para>
This error occurs at runtime if one tries to insert an illegal
</variablelist>
</para>
</refsect3>
-
+
<refsect3>
<title>Description</title>
<para>
<synopsis>
[ CONSTRAINT <replaceable class="PARAMETER">name</replaceable> ] PRIMARY KEY
</synopsis>
-
+
<refsect3>
<title>Inputs</title>
<para>
<variablelist>
<varlistentry>
- <term>
-CONSTRAINT <replaceable class="PARAMETER">name</replaceable>
- </term>
+ <term>CONSTRAINT <replaceable class="PARAMETER">name</replaceable></term>
<listitem>
<para>
An arbitrary name for the constraint.
<title>Outputs</title>
<variablelist>
<varlistentry>
- <term>
-<returnvalue>ERROR: Cannot insert a duplicate key into a unique index.</returnvalue>
- </term>
+ <term><computeroutput>
+ERROR: Cannot insert a duplicate key into a unique index.
+ </computeroutput></term>
<listitem>
<para>
This occurs at run-time if one tries to insert a duplicate value into
<title>Description</title>
<para>
The PRIMARY KEY column constraint specifies that a column of a table
- may contain only unique
+ may contain only unique
(non-duplicate), non-NULL values. The definition of
the specified column does not have to include an explicit NOT NULL
constraint to be included in a PRIMARY KEY constraint.
</title>
<para>
<productname>Postgres</productname> automatically creates
- a unique index to assure
+ a unique index to assure
data integrity. (See CREATE INDEX statement)
</para>
<para>
The PRIMARY KEY constraint should name a set of columns that is
different from other sets of columns named by any UNIQUE constraint
defined for the same table, since it will result in duplication
-of equivalent indexes and unproductive additional runtime overhead.
-However, <productname>Postgres</productname> does not specifically
-disallow this.
+ of equivalent indexes and unproductive additional runtime overhead.
+ However, <productname>Postgres</productname> does not specifically
+ disallow this.
</para>
</refsect3>
</refsect2>
</title>
<para>
<synopsis>
- [ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( <replaceable
- class="parameter">column</replaceable> [, ...] )
- [ CONSTRAINT name ] CHECK ( <replaceable>constraint</replaceable> )
+[ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( <replaceable class="parameter">column</replaceable> [, ...] )
+[ CONSTRAINT name ] CHECK ( <replaceable>constraint</replaceable> )
</synopsis>
</para>
<refsect2 id="R2-SQL-TABLECONSTRAINT-1">
<title>
Inputs
</title>
-
+
<para>
+
<variablelist>
<varlistentry>
- <term>
- CONSTRAINT <replaceable class="parameter">name</replaceable>
- </term>
+ <term>CONSTRAINT <replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
An arbitrary name given to an integrity constraint.
</listitem>
</varlistentry>
<varlistentry>
- <term>
- <replaceable class="parameter">column</replaceable> [, ...]
- </term>
+ <term><replaceable class="parameter">column</replaceable> [, ...]</term>
<listitem>
<para>
The column name(s) for which to define a unique index
</listitem>
</varlistentry>
<varlistentry>
- <term>
- CHECK ( <replaceable class="parameter">constraint</replaceable> )
- </term>
+ <term>CHECK ( <replaceable class="parameter">constraint</replaceable> )</term>
<listitem>
<para>
A boolean expression to be evaluated as the constraint.
</title>
<para>
<synopsis>
- [ CONSTRAINT <replaceable class="parameter">name</replaceable> ]
- UNIQUE ( <replaceable class="parameter">column</replaceable> [, ...] )
+[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] UNIQUE ( <replaceable class="parameter">column</replaceable> [, ...] )
</synopsis>
</para>
<refsect3>
<title>Inputs</title>
<variablelist>
<varlistentry>
- <term>
- CONSTRAINT <replaceable class="parameter">name</replaceable>
- </term>
+ <term>CONSTRAINT <replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
An arbitrary name given to a constraint.
</listitem>
</varlistentry>
<varlistentry>
- <term>
- <replaceable class="parameter">column</replaceable>
- </term>
+ <term><replaceable class="parameter">column</replaceable></term>
<listitem>
<para>
A name of a column in a table.
<para>
<variablelist>
<varlistentry>
- <term>
- <replaceable>status</replaceable>
- </term>
+ <term><replaceable>status</replaceable></term>
<listitem>
<para>
<variablelist>
<varlistentry>
- <term>
- ERROR: Cannot insert a duplicate key into a unique index.
- </term>
+ <term>ERROR: Cannot insert a duplicate key into a unique index</term>
<listitem>
<para>
This error occurs at runtime if one tries to insert a
<para>
Define a UNIQUE table constraint for the table distributors:
<programlisting>
- CREATE TABLE distributors (
- did DECIMAL(03),
- name VARCHAR(40),
- UNIQUE(name)
- );
+CREATE TABLE distributors (
+ did DECIMAL(03),
+ name VARCHAR(40),
+ UNIQUE(name)
+);
</programlisting>
</para>
</refsect3>
</title>
<para>
<synopsis>
- [ CONSTRAINT <replaceable class="PARAMETER">name</replaceable> ]
- PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] )
+[ CONSTRAINT <replaceable class="PARAMETER">name</replaceable> ] PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] )
</synopsis>
</para>
<refsect3>
<title>Inputs</title>
<para>
+
<variablelist>
<varlistentry>
- <term>
- CONSTRAINT <returnvalue><replaceable class="PARAMETER">name</replaceable></returnvalue>
- </term>
+ <term>CONSTRAINT <replaceable class="PARAMETER">name</replaceable></term>
<listitem>
<para>
An arbitrary name for the constraint.
</listitem>
</varlistentry>
<varlistentry>
- <term>
- <replaceable class="PARAMETER">column</replaceable> [, ...]
- </term>
+ <term><replaceable class="PARAMETER">column</replaceable> [, ...]</term>
<listitem>
<para>
The names of one or more columns in the table.
<title>Outputs</title>
<variablelist>
<varlistentry>
- <term>
- <replaceable>status</replaceable>
- </term>
+ <term><replaceable>status</replaceable></term>
<listitem>
<para>
<variablelist>
(non duplicate), non-null values. The column definitions of
the specified columns do not have to include a NOT NULL
constraint to be included in a PRIMARY KEY constraint.
-
+ </para>
+
+ <para>
The PRIMARY KEY table constraint is similar to that for column constraints,
with the additional capability of encompassing multiple columns.
</para>
information.
</para>
</refsect3>
-
+
</refsect2>
-
+
</refsect1>
<refsect1 id="R1-SQL-CREATETABLE-2">
Usage
</title>
<para>
- Create table films and table distributors
- </para>
- <programlisting>
- CREATE TABLE films (
- code CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY,
- title CHARACTER VARYING(40) NOT NULL,
- did DECIMAL(3) NOT NULL,
- date_prod DATE,
- kind CHAR(10),
- len INTERVAL HOUR TO MINUTE
- );
- </programlisting>
+ Create table films and table distributors:
- <programlisting>
- CREATE TABLE distributors (
- did DECIMAL(03) PRIMARY KEY DEFAULT NEXTVAL('serial'),
- name VARCHAR(40) NOT NULL CHECK (name <> '')
- );
- </programlisting>
+ <programlisting>
+CREATE TABLE films (
+ code CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY,
+ title CHARACTER VARYING(40) NOT NULL,
+ did DECIMAL(3) NOT NULL,
+ date_prod DATE,
+ kind CHAR(10),
+ len INTERVAL HOUR TO MINUTE
+);
+ </programlisting>
- <para>
- Create a table with a 2-dimensional array
+ <programlisting>
+CREATE TABLE distributors (
+ did DECIMAL(03) PRIMARY KEY DEFAULT NEXTVAL('serial'),
+ name VARCHAR(40) NOT NULL CHECK (name <> '')
+);
+ </programlisting>
</para>
- <programlisting>
+
+ <para>
+ Create a table with a 2-dimensional array:
+
+ <programlisting>
CREATE TABLE array (
vector INT[][]
);
- </programlisting>
-
+ </programlisting>
+ </para>
+
<para>
Define a UNIQUE table constraint for the table films.
UNIQUE table constraints can be defined on one or more
- columns of the table
+ columns of the table:
+
+ <programlisting>
+CREATE TABLE films (
+ code CHAR(5),
+ title VARCHAR(40),
+ did DECIMAL(03),
+ date_prod DATE,
+ kind CHAR(10),
+ len INTERVAL HOUR TO MINUTE,
+ CONSTRAINT production UNIQUE(date_prod)
+);
+ </programlisting>
</para>
- <programlisting>
- CREATE TABLE films (
- code CHAR(5),
- title VARCHAR(40),
- did DECIMAL(03),
- date_prod DATE,
- kind CHAR(10),
- len INTERVAL HOUR TO MINUTE,
- CONSTRAINT production UNIQUE(date_prod)
- );
- </programlisting>
<para>
- Define a CHECK column constraint.
+ Define a CHECK column constraint:
+
+ <programlisting>
+CREATE TABLE distributors (
+ did DECIMAL(3) CHECK (did > 100),
+ name VARCHAR(40)
+);
+ </programlisting>
</para>
- <programlisting>
- CREATE TABLE distributors (
- did DECIMAL(3) CHECK (did > 100),
- name VARCHAR(40)
- );
- </programlisting>
-
+
<para>
- Define a CHECK table constraint
+ Define a CHECK table constraint:
+
+ <programlisting>
+CREATE TABLE distributors (
+ did DECIMAL(3),
+ name VARCHAR(40)
+ CONSTRAINT con1 CHECK (did > 100 AND name > '')
+);
+ </programlisting>
</para>
- <programlisting>
- CREATE TABLE distributors (
- did DECIMAL(3),
- name VARCHAR(40)
- CONSTRAINT con1 CHECK (did > 100 AND name > '')
- );
- </programlisting>
-
+
<para>
Define a PRIMARY KEY table constraint for the table films.
PRIMARY KEY table constraints can be defined on one or more
- columns of the table
+ columns of the table:
+
+ <programlisting>
+CREATE TABLE films (
+ code CHAR(05),
+ title VARCHAR(40),
+ did DECIMAL(03),
+ date_prod DATE,
+ kind CHAR(10),
+ len INTERVAL HOUR TO MINUTE,
+ CONSTRAINT code_title PRIMARY KEY(code,title)
+);
+ </programlisting>
</para>
- <programlisting>
- CREATE TABLE films (
- code CHAR(05),
- title VARCHAR(40),
- did DECIMAL(03),
- date_prod DATE,
- kind CHAR(10),
- len INTERVAL HOUR TO MINUTE,
- CONSTRAINT code_title PRIMARY KEY(code,title)
- );
- </programlisting>
-
+
<para>
Defines a PRIMARY KEY column constraint for table distributors.
PRIMARY KEY column constraints can only be defined on one column
- of the table (the following two examples are equivalent)
+ of the table (the following two examples are equivalent):
+
+ <programlisting>
+CREATE TABLE distributors (
+ did DECIMAL(03),
+ name CHAR VARYING(40),
+ PRIMARY KEY(did)
+);
+ </programlisting>
+
+ <programlisting>
+CREATE TABLE distributors (
+ did DECIMAL(03) PRIMARY KEY,
+ name VARCHAR(40)
+);
+ </programlisting>
</para>
- <programlisting>
- CREATE TABLE distributors (
- did DECIMAL(03),
- name CHAR VARYING(40),
- PRIMARY KEY(did)
- );
-
- CREATE TABLE distributors (
- did DECIMAL(03) PRIMARY KEY,
- name VARCHAR(40)
- );
- </programlisting>
<refsect2 id="R2-SQL-CREATETABLE-3">
<refsect2info>
SQL92
</title>
<para>
- In addition to the normal CREATE TABLE, SQL92 also defines a
- CREATE TEMPORARY TABLE statement:
- </para>
+ In addition to the locally-visible temporary table, SQL92 also defines a
+ CREATE GLOBAL TEMPORARY TABLE statement, and optionally an
+ ON COMMIT clause:
<synopsis>
- CREATE [ {GLOBAL | LOCAL} ] TEMPORARY TABLE table (
- column type [DEFAULT value] [CONSTRAINT column_constraint] [, ...] )
- [CONSTRAINT table_constraint ]
- [ ON COMMIT {DELETE | PRESERVE} ROWS ]
+CREATE GLOBAL TEMPORARY TABLE <replaceable class="parameter">table</replaceable> ( <replaceable class="parameter">column</replaceable> <replaceable class="parameter">type</replaceable> [
+ DEFAULT <replaceable class="parameter">value</replaceable> ] [ CONSTRAINT <replaceable class="parameter">column_constraint</replaceable> ] [, ...] )
+ [ CONSTRAINT <replaceable class="parameter">table_constraint</replaceable> ] [ ON COMMIT { DELETE | PRESERVE } ROWS ]
</synopsis>
+ </para>
+
<para>
- For temporary tables, the CREATE TEMPORARY TABLE statement
- names a new table and defines the table's columns and
+ For temporary tables, the CREATE GLOBAL TEMPORARY TABLE statement
+ names a new table visible to other clients and defines the table's columns and
constraints.
</para>
<para>
</para>
<para>
To create a temporary table:
+
+ <programlisting>
+CREATE TEMPORARY TABLE actors (
+ id DECIMAL(03),
+ name VARCHAR(40),
+ CONSTRAINT actor_id CHECK (id < 150)
+) ON COMMIT DELETE ROWS;
+ </programlisting>
</para>
- <programlisting>
- CREATE TEMPORARY TABLE actors (
- id DECIMAL(03),
- name VARCHAR(40),
- CONSTRAINT actor_id CHECK (id < 150)
- ) ON COMMIT DELETE ROWS
- </programlisting>
- <para>
- Temporary tables are not currently available
- in <productname>Postgres</productname>.
- <tip>
- <para>
- In the current release of <productname>Postgres</productname>
- (v6.5), to create a temporary
- table you must create and drop the table by explicit commands.
- </para>
- </tip>
- </para>
-
+
<refsect3 id="R3-SQL-UNIQUECLAUSE-1">
<refsect3info>
<date>1998-09-11</date>
SQL92 specifies some additional capabilities for UNIQUE:
</para>
<para>
- Table Constraint definition
+ Table Constraint definition:
+
+ <synopsis>
+[ CONSTRAINT name ] UNIQUE ( column [, ...] )
+ [ { INITIALLY DEFERRED | INITIALLY IMMEDIATE } ]
+ [ [ NOT ] DEFERRABLE ]
+ </synopsis>
</para>
- <synopsis>
- [ CONSTRAINT name ]
- UNIQUE ( column [, ...] )
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
- </synopsis>
+
<para>
- Column Constraint definition
- </para>
- <synopsis>
- [ CONSTRAINT name ]
- UNIQUE
+ Column Constraint definition:
+
+ <synopsis>
+[ CONSTRAINT name ] UNIQUE
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
[ [ NOT ] DEFERRABLE ]
- </synopsis>
+ </synopsis>
+ </para>
</refsect3>
<refsect3 id="R3-SQL-NULL-1">
is a <productname>Postgres</productname> extension to SQL92
is included for symmetry with the NOT NULL clause. Since it is the default
for any column, its presence is simply noise.
- <synopsis>
- [ CONSTRAINT name ] NULL
- </synopsis>
-</para>
+ <synopsis>
+[ CONSTRAINT name ] NULL
+ </synopsis>
+ </para>
</refsect3>
<refsect3 id="R3-SQL-NOTNULL-4">
<para>
SQL92 specifies some additional capabilities for NOT NULL:
+ <synopsis>
+[ CONSTRAINT name ] NOT NULL
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+ </synopsis>
</para>
- <synopsis>
- [ CONSTRAINT name ] NOT NULL
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
- </synopsis>
</refsect3>
<!--
</synopsis>
</refsect3>
-->
-
+
<refsect3 id="R3-SQL-CONSTRAINT-3">
<refsect3info>
<date>1998-09-11</date>
constraint:
</para>
<synopsis>
- CREATE ASSERTION name CHECK ( condition )
+CREATE ASSERTION name CHECK ( condition )
</synopsis>
<para>
</para>
<para>
Domain constraint:
+
+ <synopsis>
+[ CONSTRAINT name ] CHECK constraint
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+ </synopsis>
</para>
- <synopsis>
- [ CONSTRAINT name ]
- CHECK constraint
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
- </synopsis>
+
<para>
Table constraint definition:
+
+ <synopsis>
+[ CONSTRAINT name ] { PRIMARY KEY ( <replaceable class="parameter">column</replaceable>, ... ) | FOREIGN KEY constraint | UNIQUE constraint | CHECK constraint }
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+ </synopsis>
</para>
- <synopsis>
- [ CONSTRAINT name ]
- { PRIMARY KEY constraint |
- FOREIGN KEY constraint |
- UNIQUE constraint |
- CHECK constraint }
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]</synopsis>
+
<para>
Column constraint definition:
+
+ <synopsis>
+[ CONSTRAINT name ] { NOT NULL | PRIMARY KEY | FOREIGN KEY constraint | UNIQUE | CHECK constraint }
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+ </synopsis>
</para>
- <synopsis>
- [ CONSTRAINT name ]
- { NOT NULL constraint |
- PRIMARY KEY constraint |
- FOREIGN KEY constraint |
- UNIQUE constraint |
- CHECK constraint }
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
- </synopsis>
+
<para>
A CONSTRAINT definition may contain one deferment attribute
clause and/or one initial constraint mode clause, in any order.
-->
<para>
table constraint definition:
- </para>
- <synopsis>
- [ CONSTRAINT name ]
- CHECK ( VALUE condition )
+ <synopsis>
+[ CONSTRAINT name ] CHECK ( VALUE condition )
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
[ [ NOT ] DEFERRABLE ]
- </synopsis>
+ </synopsis>
+ </para>
+
<para>
column constraint definition:
- </para>
<synopsis>
- [ CONSTRAINT name ]
- CHECK ( VALUE condition )
+[ CONSTRAINT name ] CHECK ( VALUE condition )
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
[ [ NOT ] DEFERRABLE ]
</synopsis>
+ </para>
<!--
- <para>
+ <para>
domain constraint definition:
</para>
<synopsis>
a CREATE DOMAIN statement or an ALTER DOMAIN statement:
</para>
<programlisting>
- CREATE DOMAIN duration AS SMALLINT
- CONSTRAINT minutes CHECK (VALUE IN (90,120,180,240));
+CREATE DOMAIN duration AS SMALLINT
+ CONSTRAINT minutes CHECK (VALUE IN (90,120,180,240));
- ALTER DOMAIN cities
- ADD CONSTRAINT new_city CHECK (VALUE LIKE 'L%');
- </programlisting>
+ALTER DOMAIN cities
+ ADD CONSTRAINT new_city CHECK (VALUE LIKE 'L%');
+ </programlisting>
-->
</refsect3>
-
-
+
<refsect3 id="R3-SQL-PRIMARYKEY-1">
<refsect3info>
<date>1998-09-11</date>
</para>
<para>
Table Constraint definition:
+ <synopsis>
+[ CONSTRAINT name ] PRIMARY KEY ( column [, ...] )
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+ </synopsis>
</para>
- <synopsis>
- [ CONSTRAINT name ]
- PRIMARY KEY ( column [, ...] )
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
- </synopsis>
<para>
Column Constraint definition:
+ <synopsis>
+[ CONSTRAINT name ] PRIMARY KEY
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+ </synopsis>
</para>
- <synopsis>
- [ CONSTRAINT name ]
- PRIMARY KEY
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
- </synopsis>
</refsect3>
</refsect2>
</refsect1>
<variablelist>
<varlistentry>
- <term>
- <replaceable>table</replaceable>
- </term>
+ <term><replaceable>table</replaceable></term>
<listitem>
<para>
The name of a new table to be created.
</varlistentry>
<varlistentry>
- <term>
- <replaceable>column</replaceable>
- </term>
- <listitem>
- <para>
- The name of a column. Multiple column names can be specified using
-a comma-delimited list of column names.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable>select_clause</replaceable>
- </term>
- <listitem>
- <para>
-A valid query statement. Refer to SELECT for a description of the
-allowed syntax.
+ <term><replaceable>column</replaceable></term>
+ <listitem>
+ <para>
+ The name of a column. Multiple column names can be specified using
+ a comma-delimited list of column names.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable>select_clause</replaceable></term>
+ <listitem>
+ <para>
+ A valid query statement. Refer to SELECT for a description of the
+ allowed syntax.
</para>
</listitem>
</varlistentry>
Outputs
</title>
<para>
- Refer to CREATE TABLE and SELECT for a summary of possible output
+ Refer to <command>CREATE TABLE</command>
+ and <command>SELECT</command> for a summary of possible output
messages.
</para>
</refsect2>
<title>
Description
</title>
- <para>
-CREATE TABLE AS enables a table to be created from the contents of
-an existing table. It has functionality equivalent to SELECT TABLE INTO,
-but with perhaps a more obvious syntax.
+ <para>
+ <command>CREATE TABLE AS</command> enables a table to be created from the contents of
+ an existing table. It has functionality equivalent to <command>SELECT TABLE INTO</command>,
+ but with perhaps a more direct syntax.
</para>
</refsect1>
</refentry>
-<REFENTRY ID="SQL-CREATETRIGGER">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATETRIGGER">
+ <refmeta>
+ <refentrytitle>
CREATE TRIGGER
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE TRIGGER
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Creates a new trigger
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-21</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-CREATE TRIGGER <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> { BEFORE | AFTER }
- { <REPLACEABLE CLASS="PARAMETER">event</REPLACEABLE> [OR ...] }
- ON <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> FOR EACH { ROW | STATEMENT }
- EXECUTE PROCEDURE <REPLACEABLE CLASS="PARAMETER">funcname</REPLACEABLE> ( <REPLACEABLE CLASS="PARAMETER">arguments</REPLACEABLE> )
- </SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-21</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTER } { <replaceable class="PARAMETER">event</replaceable> [OR ...] }
+ ON <replaceable class="PARAMETER">table</replaceable> FOR EACH { ROW | STATEMENT }
+ EXECUTE PROCEDURE <replaceable class="PARAMETER">ER">func</replaceable>BLE> ( <replaceable class="PARAMETER">arguments</replaceable> )
+ </synopsis>
- <REFSECT2 ID="R2-SQL-CREATETRIGGER-1">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATETRIGGER-1">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue><replaceable class="parameter">name</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of an existing trigger.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue><replaceable class="parameter">table</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a table.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue><replaceable class="parameter">event</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- One of INSERT, DELETE or UPDATE.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue><replaceable class="parameter">funcname</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- A user-supplied function.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATETRIGGER-2">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing trigger.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">table</replaceable></term>
+ <listitem>
+ <para>
+ The name of a table.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">event</replaceable></term>
+ <listitem>
+ <para>
+ One of INSERT, DELETE or UPDATE.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">funcname</replaceable></term>
+ <listitem>
+ <para>
+ A user-supplied function.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CREATETRIGGER-2">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message is returned if the trigger is successfully created.
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message is returned if the trigger is successfully created.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
+ </refsect2>
+ </refsynopsisdiv>
- <REFSECT1 ID="R1-SQL-CREATETRIGGER-1">
- <REFSECT1INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT1INFO>
- <TITLE>
+ <refsect1 id="R1-SQL-CREATETRIGGER-1">
+ <refsect1info>
+ <date>1998-09-21</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE TRIGGER</command> will enter a new trigger into the current
data base. The trigger will be associated with the relation
<replaceable class="parameter">relname</replaceable> and will execute
the specified function <replaceable class="parameter">funcname</replaceable>.
- </PARA>
- <PARA>
+ </para>
+ <para>
The trigger can be specified to fire either before the
operation is attempted on a tuple (before constraints
are checked and the INSERT, UPDATE or DELETE is attempted) or
being inserted (for INSERT and UPDATE operations only). If
the trigger fires after the event, all changes, including the
last insertion, update, or deletion, are "visible" to the trigger.
- </PARA>
- <PARA>
+ </para>
+ <para>
Refer to the chapters on SPI and Triggers in the
<citetitle>PostgreSQL Programmer's Guide</citetitle> for more
information.
- </PARA>
- <REFSECT2 ID="R2-SQL-CREATETRIGGER-3">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+ <refsect2 id="R2-SQL-CREATETRIGGER-3">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE TRIGGER</command> is a <productname>Postgres</productname>
language extension.
- </PARA>
- <PARA>
- Only the relation owner may create a trigger on this relation.
- </PARA>
- <PARA>
- As of the current release (v6.4), STATEMENT triggers are not implemented.
- </PARA>
- <PARA>
+ </para>
+ <para>
+ Only the relation owner may create a trigger on this relation.
+ </para>
+ <para>
+ As of the current release (v6.4), STATEMENT triggers are not implemented.
+ </para>
+ <para>
Refer to <command>DROP TRIGGER</command> for information on how to
remove triggers.
- </PARA>
- </REFSECT2>
+ </para>
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATETRIGGER-2">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATETRIGGER-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Check if the specified distributor code exists in the distributors
table before appending or updating a row in the table films:
- </PARA>
- <ProgramListing>
- CREATE TRIGGER if_dist_exists
- BEFORE INSERT OR UPDATE ON films FOR EACH ROW
- EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
- </ProgramListing>
- <PARA>
+
+ <programlisting>
+CREATE TRIGGER if_dist_exists
+ BEFORE INSERT OR UPDATE ON films FOR EACH ROW
+ EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
+ </programlisting>
+ </para>
+ <para>
Before cancelling a distributor or updating its code, remove every
reference to the table films:
- </PARA>
- <ProgramListing>
- CREATE TRIGGER if_film_exists
- BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
- EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
- </ProgramListing>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-CREATETRIGGER-3">
- <TITLE>
+ <programlisting>
+CREATE TRIGGER if_film_exists
+ BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
+ EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
+ </programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-CREATETRIGGER-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
+ </title>
+ <para>
+ </para>
- <REFSECT2 ID="R2-SQL-CREATETRIGGER-4">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATETRIGGER-4">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
There is no <command>CREATE TRIGGER</command> in <acronym>SQL92</acronym>.
- </PARA>
- <PARA>
+ </para>
+
+ <para>
The second example above may also be done by using a FOREIGN KEY
constraint as in:
- </PARA>
- <ProgramListing>
- CREATE TABLE distributors (
+
+ <programlisting>
+CREATE TABLE distributors (
did DECIMAL(3),
name VARCHAR(40),
CONSTRAINT if_film_exists
FOREIGN KEY(did) REFERENCES films
ON UPDATE CASCADE ON DELETE CASCADE
- );
- </ProgramListing>
- <PARA>
+);
+ </programlisting>
+ </para>
+
+ <para>
However, foreign keys are not yet implemented (as of version 6.4) in
<productname>Postgres</productname>.
- </PARA>
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-CREATETYPE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATETYPE">
+ <refmeta>
+ <refentrytitle>
CREATE TYPE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE TYPE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Defines a new base data type
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-21</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-21</date>
+ </refsynopsisdivinfo>
+ <synopsis>
CREATE TYPE <replaceable class="parameter">typename</replaceable> (
INPUT = <replaceable class="parameter">input_function</replaceable>
, OUTPUT = <replaceable class="parameter">output_function</replaceable>
[ , RECEIVE = <replaceable class="parameter">receive_function</replaceable> ]
[ , PASSEDBYVALUE ]
)
- </SYNOPSIS>
+ </synopsis>
- <REFSECT2 ID="R2-SQL-CREATETYPE-1">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATETYPE-1">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">typename</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a type to be created.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-INTERNALLENGTH <replaceable class="parameter">internallength</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- A literal value, which specifies the internal length of
- the new type.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
-EXTERNALLENGTH <replaceable class="parameter">externallength</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- A literal value, which specifies the external length of
- the new type.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- INPUT <replaceable class="parameter">input_function</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a function, created by CREATE FUNCTION, which
- converts data from its external form to the type's
- internal form.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- OUTPUT <replaceable class="parameter">output_function</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a function, created by CREATE FUNCTION, which
- converts data from its internal form to a form suitable
- for display.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">element</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The type being created is an array; this specifies
- the type of the array elements.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">delimiter</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The delimiter character for the array.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">default</replaceable
- </TERM>
- <LISTITEM>
- <PARA>
- The default text to be displayed to indicate "data
- not present"
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">send_function</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a function, created by CREATE FUNCTION, which
- converts data of this type into a form suitable for
- transmission to another machine.
-<comment>Is this right?</comment>
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">receive_function</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a function, created by CREATE FUNCTION, which
- converts data of this type from a form suitable for
- transmission from another machine to internal form.
-<comment>Is this right?</comment>
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATETYPE-2">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">typename</replaceable></term>
+ <listitem>
+ <para>
+ The name of a type to be created.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>INTERNALLENGTH <replaceable class="parameter">internallength</replaceable></term>
+ <listitem>
+ <para>
+ A literal value, which specifies the internal length of
+ the new type.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>EXTERNALLENGTH <replaceable class="parameter">externallength</replaceable></term>
+ <listitem>
+ <para>
+ A literal value, which specifies the external length of
+ the new type.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>INPUT <replaceable class="parameter">input_function</replaceable></term>
+ <listitem>
+ <para>
+ The name of a function, created by CREATE FUNCTION, which
+ converts data from its external form to the type's
+ internal form.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>OUTPUT <replaceable class="parameter">output_function</replaceable></term>
+ <listitem>
+ <para>
+ The name of a function, created by CREATE FUNCTION, which
+ converts data from its internal form to a form suitable
+ for display.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">element</replaceable></term>
+ <listitem>
+ <para>
+ The type being created is an array; this specifies
+ the type of the array elements.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">delimiter</replaceable></term>
+ <listitem>
+ <para>
+ The delimiter character for the array.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">default</replaceable></term>
+ <listitem>
+ <para>
+ The default text to be displayed to indicate "data
+ not present"
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">send_function</replaceable></term>
+ <listitem>
+ <para>
+ The name of a function, created by CREATE FUNCTION, which
+ converts data of this type into a form suitable for
+ transmission to another machine.
+ <comment>Is this right?</comment>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">receive_function</replaceable></term>
+ <listitem>
+ <para>
+ The name of a function, created by CREATE FUNCTION, which
+ converts data of this type from a form suitable for
+ transmission from another machine to internal form.
+ <comment>Is this right?</comment>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CREATETYPE-2">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the type is successfully created.
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the type is successfully created.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATETYPE-1">
- <REFSECT1INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATETYPE-1">
+ <refsect1info>
+ <date>1998-09-21</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
- CREATE TYPE allows the user to register a new user data
+ </title>
+ <para>
+ <command>CREATE TYPE</command> allows the user to register a new user data
type with Postgres for use in the current data base. The
user who defines a type becomes its owner.
- <replaceable class="parameter">Typename</replaceable> is
+ <replaceable class="parameter">typename</replaceable> is
the name of the new type and must be unique within the
types defined for this database.
</para>
- <PARA>
- CREATE TYPE requires the registration of two functions
+ <para>
+ <command>CREATE TYPE</command> requires the registration of two functions
(using create function) before defining the type. The
representation of a new base type is determined by
<replaceable class="parameter">input_function</replaceable>, which
the input and output functions must be declared to take
one or two arguments of type "<literal>opaque</literal>".
</para>
- <PARA>
+ <para>
New base data types can be fixed length, in which case
<replaceable class="parameter">internallength</replaceable> is a
positive integer, or variable length,
as the Postgres-supplied data type, "<literal>text</literal>".
To indicate that a type is variable-length, set
<replaceable class="parameter">internallength</replaceable>
- to VARIABLE.
+ to <option>VARIABLE</option>.
The external representation is similarly specified using the
<replaceable class="parameter">externallength</replaceable>
keyword.
</para>
- <PARA>
+ <para>
To indicate that a type is an array and to indicate that a
type has array elements, indicate the type of the array
element using the element keyword. For example, to define
an array of 4 byte integers ("int4"), specify
<programlisting>ELEMENT = int4</programlisting>
</para>
- <PARA>
+ <para>
To indicate the delimiter to be used on arrays of this
type, <replaceable class="parameter">delimiter</replaceable>
can be
set to a specific character. The default delimiter is the comma
("<literal>,</literal>").
</para>
- <PARA>
+ <para>
A default value is optionally available in case a user
wants some specific bit pattern to mean "data not present."
- Specify the default with the DEFAULT keyword.
-<comment>How does the user specify that bit pattern and associate
-it with the fact that the data is not present></comment>
+ Specify the default with the <literal>DEFAULT</literal> keyword.
+ <comment>How does the user specify that bit pattern and associate
+ it with the fact that the data is not present></comment>
</para>
- <PARA>
+ <para>
The optional functions
<replaceable class="parameter">send_function</replaceable> and
<replaceable class="parameter">receive_function</replaceable>
characters do not have to be converted if passed from
a Sun-4 to a DECstation, but many other types do.
</para>
- <PARA>
- The optional flag, PASSEDBYVALUE, indicates that operators
+ <para>
+ The optional flag, <option>PASSEDBYVALUE</option>, indicates that operators
and functions which use this data type should be passed an
argument by value rather than by reference. Note that you
may not pass by value types whose internal representation is
more than four bytes.
</para>
- <PARA>
+ <para>
For new base types, a user can define operators, functions
and aggregates using the appropriate facilities described
in this section.
</para>
+
<refsect2>
<title>Array Types</title>
<para>
- Two generalized built-in functions, array_in and
- array_out, exist for quick creation of variable-length
- array types. These functions operate on arrays of any
- existing Postgres type.</para>
+ Two generalized built-in functions, array_in and
+ array_out, exist for quick creation of variable-length
+ array types. These functions operate on arrays of any
+ existing Postgres type.
+ </para>
</refsect2>
<refsect2>
type in a class definition:
</para>
<programlisting>
- CREATE TYPE box (INTERNALLENGTH = 8,
- INPUT = my_procedure_1, OUTPUT = my_procedure_2)
-
- CREATE TABLE myboxes (id INT4, description box)
+CREATE TYPE box (INTERNALLENGTH = 8,
+ INPUT = my_procedure_1, OUTPUT = my_procedure_2);
+CREATE TABLE myboxes (id INT4, description box);
</programlisting>
<para>
This command creates a variable length array type with
integer elements.
- </para>
- <programlisting>
- CREATE TYPE int4array
- (INPUT = array_in, OUTPUT = array_out,
- INTERNALLENGTH = VARIABLE, ELEMENT = int4)
- CREATE TABLE myarrays (id int4, numbers int4array)
- </programlisting>
+ <programlisting>
+CREATE TYPE int4array (INPUT = array_in, OUTPUT = array_out,
+ INTERNALLENGTH = VARIABLE, ELEMENT = int4);
+CREATE TABLE myarrays (id int4, numbers int4array);
+ </programlisting>
+ </para>
<para>
This command creates a large object type and uses it in
- a class definition.
+ a class definition:
+
+ <programlisting>
+CREATE TYPE bigobj (INPUT = lo_filein, OUTPUT = lo_fileout,
+ INTERNALLENGTH = VARIABLE);
+CREATE TABLE big_objs (id int4, obj bigobj);
+ </programlisting>
</para>
- <programlisting>
- CREATE TYPE bigobj
- (INPUT = lo_filein, OUTPUT = lo_fileout,
- INTERNALLENGTH = VARIABLE)
- CREATE TABLE big_objs (id int4, obj bigobj)
- </programlisting>
<refsect2>
<title>Restrictions</title>
<para>
</para>
</refsect2>
- <REFSECT2 ID="R2-SQL-CREATETYPE-3">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATETYPE-3">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
Refer to <command>DROP TYPE</command> to remove an existing type.
- </PARA>
- <PARA>
+ </para>
+ <para>
See also <command>CREATE FUNCTION</command>,
<command>CREATE OPERATOR</command> and the chapter on Large Objects
in the <citetitle>PostgreSQL Programmer's Guide</citetitle>.
</para>
- </REFSECT2>
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATETYPE-3">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATETYPE-3">
+ <title>
Compatibility
- </TITLE>
+ </title>
- <REFSECT2 ID="R2-SQL-CREATETYPE-4">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATETYPE-4">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
SQL3
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>CREATE TYPE</command> is an <acronym>SQL3</acronym> statement.
- </PARA>
-
- </REFSECT2>
+ </para>
+ </refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
<para>
<variablelist>
<varlistentry>
- <term>
- <returnvalue><replaceable class="parameter">username</replaceable></returnvalue>
- </term>
+ <term><replaceable class="parameter">username</replaceable></term>
<listitem>
<para>
The name of the user.
</varlistentry>
<varlistentry>
- <term>
- <returnvalue><replaceable class="parameter">password</replaceable></returnvalue>
- </term>
+ <term><replaceable class="parameter">password</replaceable></term>
<listitem>
<para>
The WITH PASSWORD clause sets the user's password within
</varlistentry>
<varlistentry>
- <term>
- <returnvalue> CREATEDB/NOCREATEDB</returnvalue>
- </term>
+ <term>CREATEDB</term>
+ <term>NOCREATEDB</term>
<listitem>
<para>
These clauses define a user's ability to create databases.
</varlistentry>
<varlistentry>
- <term>
- <returnvalue>CREATEUSER/NOCREATEUSER</returnvalue>
- </term>
+ <term>CREATEUSER</term>
+ <term>NOCREATEUSER</term>
<listitem>
<para>
These clauses determine whether a user will be permitted to
</varlistentry>
<varlistentry>
- <term>
- <returnvalue><replaceable class="parameter">groupname</replaceable></returnvalue>
- </term>
+ <term><replaceable class="parameter">groupname</replaceable></term>
<listitem>
<para>
A name of a group into which to insert the user as a new member.
</varlistentry>
<varlistentry>
- <term>
- <returnvalue><replaceable class="parameter">abstime</replaceable></returnvalue>
- </term>
+ <term><replaceable class="parameter">abstime</replaceable></term>
<listitem>
<para>
The VALID UNTIL clause sets an absolute time after which the
<para>
<variablelist>
<varlistentry>
- <term>
- <returnvalue>CREATE USER</returnvalue>
- </term>
+ <term><computeroutput>
+CREATE USER
+ </computeroutput></term>
<listitem>
<para>
Message returned if the command completes successfully.
</para>
</listitem>
</varlistentry>
-
- <varlistentry>
- <term>
- <returnvalue>ERROR: removeUser: user "<replaceable
- class="parameter">username</replaceable>" does not exist</returnvalue>
- </term>
- <listitem>
- <para>
- if "<replaceable class="parameter">username</replaceable>" not found.
- </para>
- <comment>I don't understand this and I don't know how to get
- this error message.</comment>
- </listitem>
- </varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
-
+
<refsect1 id="R1-SQL-CREATEUSER-1">
<refsect1info>
<date>1998-09-21</date>
</title>
<para>
CREATE USER will add a new user to an instance of
-<productname>Postgres</productname>.
+ <productname>Postgres</productname>.
</para>
<para>
The new user will be given a <filename>usesysid</filename> of:
- '<command>SELECT MAX(usesysid) + 1 FROM pg_shadow</command>'.
+
+ <programlisting>
+SELECT MAX(usesysid) + 1 FROM pg_shadow;
+ </programlisting>
+
This means that
<productname>Postgres</productname> users' <filename>usesysid</filename>s will not
correspond to their operating
system(OS) user ids. The exception to this rule is
- the '<literal>postgres</literal>' user, whose OS user id
+ the <literal>postgres</literal> superuser, whose OS user id
is used as the
<filename>usesysid</filename> during the initdb process.
If you still want the
OS user id and the <filename>usesysid</filename> to match
for any given user,
- use the "createuser" script provided with the <productname>Postgres</productname>
- distribution.
+ use the <application>createuser</application> script provided with
+ the <productname>Postgres</productname> distribution.
</para>
<refsect2 id="R2-SQL-CREATEUSER-3">
Notes
</title>
<para>
- CREATE USER statement is a <productname>Postgres</productname> language extension.
+ <command>CREATE USER</command> statement is a
+ <productname>Postgres</productname> language extension.
</para>
<para>
- Use DROP USER or ALTER USER statements to remove or modify a user
- account.</para>
+ Use <command>DROP USER</command> or <command>ALTER USER</command>
+ statements to remove or modify a user account.
+ </para>
<para>
Refer to the <filename>pg_shadow</filename> table for further information.
</para>
</title>
<para>
Create a user with no password:
+
+ <programlisting>
+CREATE USER jonathan
+ </programlisting>
</para>
- <programlisting>
- CREATE USER jonathan
- </programlisting>
+
<para>
Create a user with a password:
+
+ <programlisting>
+CREATE USER davide WITH PASSWORD jw8s0F4
+ </programlisting>
</para>
- <programlisting>
- CREATE USER davide WITH PASSWORD jw8s0F4
- </programlisting>
+
<para>
Create a user with a password, whose account is valid until the end of 2001.
Note that after one second has ticked in 2002, the account is not
valid:
+
+ <programlisting>
+CREATE USER miriam WITH PASSWORD jw8s0F4 VALID UNTIL 'Jan 1 2002'
+ </programlisting>
</para>
- <programlisting>
- CREATE USER miriam WITH PASSWORD jw8s0F4 VALID UNTIL 'Jan 1 2002'
- </programlisting>
+
<para>
Create an account where the user can create databases:
+
+ <programlisting>
+CREATE USER manuel WITH PASSWORD jw8s0F4 CREATEDB
+ </programlisting>
</para>
- <programlisting>
- CREATE USER manuel WITH PASSWORD jw8s0F4 CREATEDB
- </programlisting>
-
</refsect1>
<refsect1 id="R1-SQL-CREATEUSER-3">
SQL92
</title>
<para>
- There is no CREATE USER statement in SQL92.
+ There is no <command>CREATE USER</command> statement in SQL92.
</para>
</refsect2>
</refsect1>
-<REFENTRY ID="SQL-CREATEVIEW">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATEVIEW">
+ <refmeta>
+ <refentrytitle>
CREATE VIEW
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
CREATE VIEW
- </REFNAME>
- <REFPURPOSE>
-Constructs a virtual table
- </REFPURPOSE>
+ </refname>
+ <refpurpose>
+ Constructs a virtual table
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-21</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-CREATE VIEW <REPLACEABLE CLASS="PARAMETER">view</REPLACEABLE>
- AS SELECT <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-CREATEVIEW-1">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-21</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+CREATE VIEW <replaceable class="PARAMETER">view</replaceable>
+ AS SELECT <replaceable class="PARAMETER">query</replaceable>
+ </synopsis>
+
+ <refsect2 id="R2-SQL-CREATEVIEW-1">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue><replaceable class="parameter">view</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of a view to be created.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue><replaceable class="parameter">query</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
-An SQL query which will provide the columns and rows of the view.
- </PARA>
- <PARA>
- Refer to the SELECT statement for more information
- about valid arguments.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">view</replaceable></term>
+ <listitem>
+ <para>
+ The name of a view to be created.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">query</replaceable></term>
+ <listitem>
+ <para>
+ An SQL query which will provide the columns and rows of the view.
+ </para>
+ <para>
+ Refer to the SELECT statement for more information
+ about valid arguments.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-CREATEVIEW-2">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-CREATEVIEW-2">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The message returned if the view is successfully created.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>
- WARN amcreate: "<replaceable class="parameter">view</replaceable>" relation already exists
- </ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This error occurs if the view specified already exists in the database.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>NOTICE create: attribute named "<replaceable class="parameter">column</replaceable>" has an unknown type</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The view will be created having a column with an unknown type
- if you do not specify it. For example, the following command gives
- an error:
- <programlisting>
- CREATE VIEW vista AS SELECT 'Hello World'
- </programlisting>
- whereas this command does not:
- <programlisting>
- CREATE VIEW vista AS SELECT 'Hello World'::text
- </programlisting>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+CREATE
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The message returned if the view is successfully created.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: Relation '<replaceable class="parameter">view</replaceable>' already exists
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This error occurs if the view specified already exists in the database.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+NOTICE create: attribute named "<replaceable class="parameter">column</replaceable>" has an unknown type
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The view will be created having a column with an unknown type
+ if you do not specify it. For example, the following command gives
+ an error:
+ <programlisting>
+CREATE VIEW vista AS SELECT 'Hello World'
+ </programlisting>
+ whereas this command does not:
+ <programlisting>
+CREATE VIEW vista AS SELECT 'Hello World'::text
+ </programlisting>
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-CREATEVIEW-1">
- <REFSECT1INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-CREATEVIEW-1">
+ <refsect1info>
+ <date>1998-09-21</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
- CREATE VIEW will define a view of a table. This view is
+ </title>
+ <para>
+ <command>CREATE VIEW</command> will define a view of a table. This view is
not physically materialized. Specifically, a query
rewrite retrieve rule is automatically generated
to support retrieve operations on views.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-CREATEVIEW-3">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-CREATEVIEW-3">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
- Use the DROP VIEW statement to drop views.
- </PARA>
+ </title>
+ <para>
+ Use the <command>DROP VIEW</command> statement to drop views.
+ </para>
</refsect2>
-
- <REFSECT2 ID="R2-SQL-CREATEVIEW-4">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+
+ <refsect2 id="R2-SQL-CREATEVIEW-4">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
Bugs
- </TITLE>
+ </title>
<para>
- Currently, views are read only.
+ Currently, views are read only.
</para>
- </REFSECT2>
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-CREATEVIEW-2">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEVIEW-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Create a view consisting of all Comedy films:
- </PARA>
- <ProgramListing>
+
+ <programlisting>
CREATE VIEW kinds AS
SELECT *
FROM films
-----+-------------------------+---+----------+----------+------
UA502|Bananas |105|1971-07-13|Comedy | 01:22
C_701|There's a Girl in my Soup|107|1970-06-11|Comedy | 01:36
- </ProgramListing>
-
- </REFSECT1>
+ </programlisting>
+ </para>
+ </refsect1>
- <REFSECT1 ID="R1-SQL-CREATEVIEW-3">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEVIEW-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
+ </title>
+ <para>
+ </para>
- <REFSECT2 ID="R2-SQL-CREATEVIEW-5">
- <REFSECT2INFO>
- <DATE>1998-09-21</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEVIEW-5">
+ <refsect2info>
+ <date>1998-09-21</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
- SQL92 specifies some additional capabilities for the CREATE VIEW statement:
- </PARA>
+ </title>
+ <para>
+ SQL92 specifies some additional capabilities for the
+ <command>CREATE VIEW</command> statement:
+ </para>
<synopsis>
CREATE VIEW <replaceable class="parameter">view</replaceable> [ <replaceable class="parameter">column</replaceable> [, ...] ]
- AS SELECT <replaceable class="parameter">expression</replaceable> [AS <replaceable class="parameter">colname</replaceable>] [, ...]
- FROM <replaceable class="parameter">table</replaceable>
- [ WHERE <replaceable class="parameter">condition</replaceable> ]
+ AS SELECT <replaceable class="parameter">expression</replaceable> [ AS <replaceable class="parameter">colname</replaceable> ] [, ...]
+ FROM <replaceable class="parameter">table</replaceable> [ WHERE <replaceable class="parameter">condition</replaceable> ]
[ WITH [ CASCADE | LOCAL ] CHECK OPTION ]
</synopsis>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- </TERM>
- <LISTITEM>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- CHECK OPTION
- </TERM>
- <LISTITEM>
- <PARA> This option is to do with updatable views.
- All INSERTs and UPDATEs on the view will be
- checked to ensure data satisfy the view-defining
- condition. If they do not, the update will be rejected.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- LOCAL
- </TERM>
- <LISTITEM>
- <PARA>
- Check for integrity on this view.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- CASCADE
- </TERM>
- <LISTITEM>
- <PARA>
- Check for integrity on this view and on any dependent
- view. CASCADE is assumed if neither CASCADE nor LOCAL is specified.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
+ <para>
+ The optional clauses for the full SQL92 command are:
+
+ <variablelist>
+ <varlistentry>
+ <term>CHECK OPTION</term>
+ <listitem>
+ <para>
+ This option is to do with updatable views.
+ All INSERTs and UPDATEs on the view will be
+ checked to ensure data satisfy the view-defining
+ condition. If they do not, the update will be rejected.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>LOCAL</term>
+ <listitem>
+ <para>
+ Check for integrity on this view.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>CASCADE</term>
+ <listitem>
+ <para>
+ Check for integrity on this view and on any dependent
+ view. CASCADE is assumed if neither CASCADE nor LOCAL is specified.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
-
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="APP-CREATEDB">
- <REFMETA>
- <REFENTRYTITLE>
- <application>createdb</application>
- </REFENTRYTITLE>
- <REFMISCINFO>Application</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
- <application>createdb</application>
- </REFNAME>
- <REFPURPOSE>
- Create a new <productname>Postgres</productname> database
- </REFPURPOSE>
- </refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-10-02</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
- createdb [ <replaceable class="parameter">dbname</replaceable> ]
- createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
- [ -D <replaceable class="parameter">datadir</replaceable> ]
- [ -u ] [ <replaceable class="parameter">dbname</replaceable> ]
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-APP-CREATEDB-1">
- <REFSECT2INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT2INFO>
- <TITLE>
- Inputs
- </TITLE>
- <PARA>
-
- <variablelist>
- <varlistentry>
- <term>
- -h <replaceable class="parameter">host</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the hostname of the machine on which the
- <application>postmaster</application>
- is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- -p <replaceable class="parameter">port</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the Internet TCP/IP port or local Unix domain socket file
- extension on which the <application>postmaster</application>
- is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
- environment variable (if set).
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -u
- </term>
- <listitem>
- <para>
- Use password authentication.
- Prompts for
- <replaceable class="parameter">username</replaceable>
- and <replaceable class="parameter">password</replaceable>.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -D <replaceable class="parameter">datadir</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the alternate database location for this database installation.
- This is the location of the installation system tables, not the location
- of this specific database, which may be different.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="parameter">dbname</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the name of the database to be created. The name must be
- unique among all <productname>Postgres</productname> databases in this installation.
- <replaceable class="parameter">dbname</replaceable>
- defaults to the value of the
- <envar>USER</envar>
- environment variable.
- </para>
- </listitem>
- </varlistentry>
-
- </variablelist>
- </para>
- </refsect2>
+<refentry id="APP-CREATEDB">
+ <refmeta>
+ <refentrytitle>
+ <application>createdb</application>
+ </refentrytitle>
+ <refmiscinfo>Application</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ <application>createdb</application>
+ </refname>
+ <refpurpose>
+ Create a new <productname>Postgres</productname> database
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-10-02</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+createdb [ <replaceable class="parameter">dbname</replaceable> ]
+createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
+ [ -D <replaceable class="parameter">datadir</replaceable> ] [ -u ] [ <replaceable class="parameter">dbname</replaceable> ]
+ </synopsis>
- <REFSECT2 ID="R2-APP-CREATEDB-2">
- <REFSECT2INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT2INFO>
- <TITLE>
- Outputs
- </TITLE>
- <PARA>
- <application>createdb</application> will create files in the
- <filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
- data area for the new database.
-
- <variablelist>
- <varlistentry>
- <term>
- Connection to database 'template1' failed.
- connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
- createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- <application>createdb</application> could not attach to the
- <application>postmaster</application>
- process on the specified host and port. If you see this message,
- ensure that the <application>postmaster</application>
- is running on the proper host and that you have specified the proper
- port. If your site uses an authentication system, ensure that you
- have obtained the required authentication credentials.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- Connection to database 'template1' failed.
- FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
- createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- You do not have a valid entry in the relation <literal>pg_shadow</literal>
- and and will not be allowed to access <productname>Postgres</productname>.
- Contact your <productname>Postgres</productname> administrator.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
- createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- You do not have permission to create new databases.
- Contact your <productname>Postgres</productname> site administrator.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- ERROR: createdb: database '<replaceable class="parameter">dbname</replaceable>' already exists.
- createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- The database already exists.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- An internal error occurred in <application>psql</application>
- or in the backend server. Ensure that your site administrator has
- properly installed <productname>Postgres</productname>and initialized the site with
- <application>initdb</application>.
- </para>
- </listitem>
- </varlistentry>
-
- </variablelist>
- </para>
- <note>
- <para>
- <application>createdb</application> internally runs
- CREATE DATABASE from <application>psql</application>
- while connected to the <literal>template1</literal> database.
- </para>
- </note>
- </refsect2>
- </refsynopsisdiv>
-
- <REFSECT1 ID="R1-APP-CREATEDB-1">
- <REFSECT1INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT1INFO>
- <TITLE>
- Description
- </TITLE>
- <PARA>
- <application>createdb</application> creates a new
- <productname>Postgres</productname> database.
- The person who executes this command becomes
- the database administrator, or <acronym>DBA</acronym>,
- for this database and is the only
- person, other than the <productname>Postgres</productname> super-user,
- who can destroy it.
- </para>
+ <refsect2 id="R2-APP-CREATEDB-1">
+ <refsect2info>
+ <date>1998-10-02</date>
+ </refsect2info>
+ <title>
+ Inputs
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term>-h <replaceable class="parameter">host</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>-p <replaceable class="parameter">port</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-u</term>
+ <listitem>
+ <para>
+ Use password authentication.
+ Prompts for
+ <replaceable class="parameter">username</replaceable>
+ and <replaceable class="parameter">password</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-D <replaceable class="parameter">datadir</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the alternate database location for this database installation.
+ This is the location of the installation system tables, not the location
+ of this specific database, which may be different.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">dbname</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the name of the database to be created. The name must be
+ unique among all <productname>Postgres</productname> databases in this installation.
+ <replaceable class="parameter">dbname</replaceable>
+ defaults to the value of the
+ <envar>USER</envar>
+ environment variable.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-APP-CREATEDB-2">
+ <refsect2info>
+ <date>1998-10-02</date>
+ </refsect2info>
+ <title>
+ Outputs
+ </title>
+ <para>
+ <application>createdb</application> will create files in the
+ <filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
+ data area for the new database.
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+Connection to database 'template1' failed.
+connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ <application>createdb</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+Connection to database 'template1' failed.
+FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>.
+ Contact your <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
+createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You do not have permission to create new databases.
+ Contact your <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+ERROR: createdb: database '<replaceable class="parameter">dbname</replaceable>' already exists.
+createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The database already exists.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. Ensure that your site administrator has
+ properly installed <productname>Postgres</productname>and initialized the site with
+ <application>initdb</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <note>
<para>
- <application>createdb</application> is a shell script that invokes
- <application>psql</application>.
- Hence, a <application>postmaster</application>
- process must be running on the database server host before
- <application>createdb</application>
- is executed. The
- <envar>PGOPTION</envar>
- and
- <envar>PGREALM</envar>
- environment variables will be passed on to
- <application>psql</application>
- and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
+ <application>createdb</application> internally runs
+ <command>CREATE DATABASE</command> from <application>psql</application>
+ while connected to the <literal>template1</literal> database.
</para>
- </refsect1>
-
- <REFSECT1 ID="R1-APP-CREATEDB-2">
- <REFSECT1INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT1INFO>
- <TITLE>
- Usage
- </TITLE>
- <PARA>
- To create the database <literal>demo</literal>
- using the postmaster on the local host, port 5432:
-
- <programlisting>
- createdb demo
- </programlisting>
-
- To create the database <literal>demo</literal>
- using the postmaster on host eden, port 5000:
-
- <programlisting>
- createdb -p 5000 -h eden demo
- </programlisting>
- </para>
- </refsect1>
-</REFENTRY>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-APP-CREATEDB-1">
+ <refsect1info>
+ <date>1998-10-02</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
+ <application>createdb</application> creates a new
+ <productname>Postgres</productname> database.
+ The person who executes this command becomes
+ the database administrator, or <acronym>DBA</acronym>,
+ for this database and is the only
+ person, other than the <productname>Postgres</productname> super-user,
+ who can destroy it.
+ </para>
+ <para>
+ <application>createdb</application> is a shell script that invokes
+ <application>psql</application>.
+ Hence, a <application>postmaster</application>
+ process must be running on the database server host before
+ <application>createdb</application>
+ is executed. The
+ <envar>PGOPTION</envar>
+ and
+ <envar>PGREALM</envar>
+ environment variables will be passed on to
+ <application>psql</application>
+ and processed as described in <xref endterm="psql-ref"
+ linkend="app-psql">.
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-APP-CREATEDB-2">
+ <refsect1info>
+ <date>1998-10-02</date>
+ </refsect1info>
+ <title>
+ Usage
+ </title>
+ <para>
+ To create the database <literal>demo</literal>
+ using the postmaster on the local host, port 5432:
+
+ <programlisting>
+$ createdb demo
+ </programlisting>
+ </para>
+
+ <para>
+ To create the database <literal>demo</literal>
+ using the postmaster on host eden, port 5000:
+
+ <programlisting>
+$ createdb -p 5000 -h eden demo
+ </programlisting>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:nil
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:"../reference.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:"/usr/lib/sgml/catalog"
+sgml-local-ecat-files:nil
+End:
+-->
-<REFENTRY ID="APP-CREATEUSER">
-<REFMETA>
-<REFENTRYTITLE>
-<application>createuser</application>
-</REFENTRYTITLE>
-<REFMISCINFO>Application</REFMISCINFO>
-</REFMETA>
-<REFNAMEDIV>
-<REFNAME>
-<application>createuser</application>
-</REFNAME>
-<REFPURPOSE>
-Create a new <productname>Postgres</productname> user
-</REFPURPOSE>
- </refnamediv>
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-10-02</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
+<refentry id="APP-CREATEUSER">
+ <refmeta>
+ <refentrytitle>
+ <application>createuser</application>
+ </refentrytitle>
+ <refmiscinfo>Application</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ <application>createuser</application>
+ </refname>
+ <refpurpose>
+ Create a new <productname>Postgres</productname> user
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-10-02</date>
+ </refsynopsisdivinfo>
+ <synopsis>
createuser [ <replaceable class="parameter">username</replaceable> ]
createuser [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
- [ -i <replaceable class="parameter">userid</replaceable> ]
- [ -d | -D ] [ -u | -U ] [ <replaceable class="parameter">username</replaceable> ]
-</SYNOPSIS>
+ [ -i <replaceable class="parameter">userid</replaceable> ] [ -d | -D ] [ -u | -U ]
+ [ <replaceable class="parameter">username</replaceable> ]
+ </synopsis>
- <REFSECT2 ID="R2-APP-CREATEUSER-1">
- <REFSECT2INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT2INFO>
- <TITLE>
- Inputs
- </TITLE>
- <PARA>
-
- <variablelist>
- <varlistentry>
- <term>
- -h <replaceable class="parameter">host</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the hostname of the machine on which the
- <application>postmaster</application>
- is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -p <replaceable class="parameter">port</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the Internet TCP/IP port or local Unix domain socket file
- extension on which the <application>postmaster</application>
- is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
- environment variable (if set).
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -d
- </term>
- <listitem>
- <para>
- Allows the user to create databases.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -D
- </term>
- <listitem>
- <para>
- Forbids the user to create databases.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -i <replaceable class="parameter">userid</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the numeric identifier to be associated with this user.
- This identifier must be unique among all <productname>Postgres</productname> users, and is not required
- to match the operating system UID.
- You will be prompted for an identifier if none is specified on the command line,
- and it will suggest an identifier matching the UID.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -u
- </term>
- <listitem>
- <para>
- Allows the user to create other users.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -U
- </term>
- <listitem>
- <para>
- Forbids the user to create other users.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="parameter">username</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the name of the <productname>Postgres</productname> user to be created.
- This name must be unique among all <productname>Postgres</productname> users.
- You will be prompted for a name if none is specified on the command line.
- </para>
- </listitem>
- </varlistentry>
-
- </variablelist>
- </para>
- </refsect2>
+ <refsect2 id="R2-APP-CREATEUSER-1">
+ <refsect2info>
+ <date>1998-10-02</date>
+ </refsect2info>
+ <title>
+ Inputs
+ </title>
+ <para>
- <REFSECT2 ID="R2-APP-CREATEUSER-2">
- <REFSECT2INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT2INFO>
- <TITLE>
- Outputs
- </TITLE>
- <PARA>
- <application>createuser</application> will add an entry in the
- <literal>pg_user</literal> or <literal>pg_shadow</literal> system table.
-
- <variablelist>
- <varlistentry>
- <term>
- Connection to database 'template1' failed.
- connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
- createuser: database access failed.
- </term>
- <listitem>
- <para>
- <application>createuser</application> could not attach to the
- <application>postmaster</application>
- process on the specified host and port. If you see this message,
- ensure that the <application>postmaster</application>
- is running on the proper host and that you have specified the proper
- port. If your site uses an authentication system, ensure that you
- have obtained the required authentication credentials.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- Connection to database 'template1' failed.
- FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
- createuser: database access failed.
- </term>
- <listitem>
- <para>
- You do not have a valid entry in the relation <literal>pg_shadow</literal>
- and and will not be allowed to access <productname>Postgres</productname>. Contact your
- <productname>Postgres</productname> administrator.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- createuser: <replaceable class="parameter">username</replaceable> cannot create users.
- </term>
- <listitem>
- <para>
- You do not have permission to create new users; contact your
- <productname>Postgres</productname> site administrator.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- createuser: user "<replaceable class="parameter">username</replaceable>" already exists
- </term>
- <listitem>
- <para>
- The user to be added already has an entry in the <literal>pg_shadow</literal>
- class.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- database access failed
- </term>
- <listitem>
- <para>
- An internal error occurred in <application>psql</application>
- or in the backend server. Ensure that your site administrator has
- properly installed <productname>Postgres</productname>and initialized the site with
- <application>initdb</application>.
- </para>
- </listitem>
- </varlistentry>
-
- </variablelist>
- </para>
-
- <note>
- <para>
- <application>createuser</application> internally runs
- CREATE USER from <application>psql</application>
- while connected to the <literal>template1</literal> database.
- </para>
- </note>
- </refsect2>
- </refsynopsisdiv>
-
- <REFSECT1 ID="R1-APP-CREATEUSER-1">
- <REFSECT1INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT1INFO>
- <TITLE>
- Description
- </TITLE>
- <PARA>
- <application>createuser</application> creates a
- new <productname>Postgres</productname> user.
- Only users with <literal>usesuper</literal> set in
- the <literal>pg_shadow</literal> class can create
- new <productname>Postgres</productname> users. As shipped,
- the user <literal>postgres</literal> can create users.
- </para>
+ <variablelist>
+ <varlistentry>
+ <term>-h <replaceable class="parameter">host</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-p <replaceable class="parameter">port</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-d</term>
+ <listitem>
+ <para>
+ Allows the user to create databases.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-D</term>
+ <listitem>
+ <para>
+ Forbids the user to create databases.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-i <replaceable class="parameter">userid</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the numeric identifier to be associated with this user.
+ This identifier must be unique among all
+ <productname>Postgres</productname> users, and is not required
+ to match the operating system UID.
+ You will be prompted for an identifier if none is specified on the command line,
+ and it will suggest an identifier matching the UID.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-u</term>
+ <listitem>
+ <para>
+ Allows the user to create other users.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-U</term>
+ <listitem>
+ <para>
+ Forbids the user to create other users.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">username</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the name of the <productname>Postgres</productname> user to be created.
+ This name must be unique among all <productname>Postgres</productname> users.
+ You will be prompted for a name if none is specified on the command line.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-APP-CREATEUSER-2">
+ <refsect2info>
+ <date>1998-10-02</date>
+ </refsect2info>
+ <title>
+ Outputs
+ </title>
+ <para>
+ <application>createuser</application> will add an entry in the
+ <literal>pg_user</literal> or <literal>pg_shadow</literal> system table.
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+Connection to database 'template1' failed.
+connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+createuser: database access failed.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ <application>createuser</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+Connection to database 'template1' failed.
+FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+createuser: database access failed.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>. Contact your
+ <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+createuser: <replaceable class="parameter">username</replaceable> cannot create users.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You do not have permission to create new users; contact your
+ <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+createuser: user "<replaceable class="parameter">username</replaceable>" already exists
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The user to be added already has an entry in the
+ <literal>pg_shadow</literal> class.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+database access failed
+ </computeroutput></term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. Ensure that your site administrator has
+ properly installed <productname>Postgres</productname>and initialized the site with
+ <application>initdb</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+
+ <note>
<para>
- <application>createuser</application> is a shell script that invokes
- <application>psql</application>.
- Hence, a <application>postmaster</application>
- process must be running on the database server host before
- <application>createuser</application> is executed.
- The
- <envar>PGOPTION</envar>
- and
- <envar>PGREALM</envar>
- environment variables will be passed on to
- <application>psql</application>
- and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
-
- Once invoked, <application>createuser</application>
- will ask a series of questions to obtain parameters not specified on
- the command line. The new user's database login name and a numeric
- user identifier must be specified.
+ <application>createuser</application> internally runs
+ <command>CREATE USER</command> from <application>psql</application>
+ while connected to the <literal>template1</literal> database.
</para>
- <note>
- <para>
- The <productname>Postgres</productname> user identifier
- does not need to be the same as the user's Unix UID. However, typically
- they are assigned to be the same.
- </para>
- </note>
-
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-APP-CREATEUSER-1">
+ <refsect1info>
+ <date>1998-10-02</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
+ <application>createuser</application> creates a
+ new <productname>Postgres</productname> user.
+ Only users with <literal>usesuper</literal> set in
+ the <literal>pg_shadow</literal> class can create
+ new <productname>Postgres</productname> users. As shipped,
+ the user <literal>postgres</literal> can create users.
+ </para>
+ <para>
+ <application>createuser</application> is a shell script that invokes
+ <application>psql</application>.
+ Hence, a <application>postmaster</application>
+ process must be running on the database server host before
+ <application>createuser</application> is executed.
+ The
+ <envar>PGOPTION</envar>
+ and
+ <envar>PGREALM</envar>
+ environment variables will be passed on to
+ <application>psql</application>
+ and processed as described in <xref endterm="psql-ref" linkend="app-psql">.
+ </para>
+
+ <para>
+ Once invoked, <application>createuser</application>
+ will ask a series of questions to obtain parameters not specified on
+ the command line. The new user's database login name and a numeric
+ user identifier must be specified.
+
+ <note>
<para>
- You must also describe the privileges of the new user for security purposes.
- Specifically, you will be asked whether the new user should be able to
- act as <productname>Postgres</productname> super-user,
- whether the new user may create new databases and whether the new user
- is allowed to create other new users.
+ The <productname>Postgres</productname> user identifier
+ does not need to be the same as the user's Unix UID. However, typically
+ they are assigned to be the same.
</para>
- </refsect1>
-</REFENTRY>
+ </note>
+ </para>
+
+ <para>
+ You must also describe the privileges of the new user for security purposes.
+ Specifically, you will be asked whether the new user should be able to
+ act as <productname>Postgres</productname> super-user,
+ whether the new user may create new databases and whether the new user
+ is allowed to create other new users.
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:nil
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:"../reference.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:"/usr/lib/sgml/catalog"
+sgml-local-ecat-files:nil
+End:
+-->
-<REFENTRY ID="SQL-DECLARE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-DECLARE">
+ <refmeta>
+ <refentrytitle>
DECLARE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
DECLARE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Defines a cursor for table access
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-04</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-04</date>
+ </refsynopsisdivinfo>
+ <synopsis>
DECLARE <replaceable class="parameter">cursor</replaceable> [ BINARY ] [ INSENSITIVE ] [ SCROLL ]
CURSOR FOR <replaceable class="parameter">query</replaceable>
[ FOR { READ ONLY | UPDATE [ OF <replaceable class="parameter">column</replaceable> [, ...] ] ]
- </SYNOPSIS>
- <REFSECT2 ID="R2-SQL-DECLARE-1">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </synopsis>
+ <refsect2 id="R2-SQL-DECLARE-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">cursor</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of the cursor to be used in subsequent FETCH operations..
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">cursor</replaceable></term>
+ <listitem>
+ <para>
+ The name of the cursor to be used in subsequent FETCH operations..
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- BINARY
- </TERM>
- <LISTITEM>
- <PARA>
- Causes the cursor to fetch data in binary
- rather than in text format.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <varlistentry>
+ <term>BINARY</term>
+ <listitem>
+ <para>
+ Causes the cursor to fetch data in binary
+ rather than in text format.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- INSENSITIVE
- </TERM>
- <LISTITEM>
- <PARA>
- <acronym>SQL92</acronym> keyword indicating that data retrieved
-from the cursor should be unaffected by updates from other processes or cursors.
-Since cursor operations occur within transactions
- in <productname>Postgres</productname> this is always the case.
-This keyword has no effect.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <varlistentry>
+ <term>INSENSITIVE</term>
+ <listitem>
+ <para>
+ <acronym>SQL92</acronym> keyword indicating that data retrieved
+ from the cursor should be unaffected by updates from other processes or cursors.
+ Since cursor operations occur within transactions
+ in <productname>Postgres</productname> this is always the case.
+ This keyword has no effect.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- SCROLL
- </TERM>
- <LISTITEM>
- <PARA>
-<acronym>SQL92</acronym> keyword indicating that data may be retrieved
-in multiple rows per FETCH operation. Since this is allowed at all times
-by <productname>Postgres</productname> this keyword has no effect.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <varlistentry>
+ <term>SCROLL</term>
+ <listitem>
+ <para>
+ <acronym>SQL92</acronym> keyword indicating that data may be retrieved
+ in multiple rows per FETCH operation. Since this is allowed at all times
+ by <productname>Postgres</productname> this keyword has no effect.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">query</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- An SQL query which will provide the rows to be governed by the
- cursor.
- Refer to the SELECT statement for further information about
- valid arguments.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <varlistentry>
+ <term><replaceable class="parameter">query</replaceable></term>
+ <listitem>
+ <para>
+ An SQL query which will provide the rows to be governed by the
+ cursor.
+ Refer to the SELECT statement for further information about
+ valid arguments.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- READ ONLY
- </TERM>
- <LISTITEM>
- <PARA>
-<acronym>SQL92</acronym> keyword indicating that the cursor will be used
-in a readonly mode. Since this is the only cursor access mode
-available in <productname>Postgres</productname> this keyword has no effect.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <varlistentry>
+ <term>READ ONLY</term>
+ <listitem>
+ <para>
+ <acronym>SQL92</acronym> keyword indicating that the cursor will be used
+ in a readonly mode. Since this is the only cursor access mode
+ available in <productname>Postgres</productname> this keyword has no effect.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- UPDATE
- </TERM>
- <LISTITEM>
- <PARA>
-<acronym>SQL92</acronym> keyword indicating that the cursor will be used
-to update tables. Since cursor updates are not currently
-supported in <productname>Postgres</productname> this keyword
-provokes an informational error message.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <varlistentry>
+ <term>UPDATE</term>
+ <listitem>
+ <para>
+ <acronym>SQL92</acronym> keyword indicating that the cursor will be used
+ to update tables. Since cursor updates are not currently
+ supported in <productname>Postgres</productname> this keyword
+ provokes an informational error message.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">column</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
-Column(s) to be updated.
-Since cursor updates are not currently
-supported in <productname>Postgres</productname> the UPDATE clause
-provokes an informational error message.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <varlistentry>
+ <term><replaceable class="parameter">column</replaceable></term>
+ <listitem>
+ <para>
+ Column(s) to be updated.
+ Since cursor updates are not currently
+ supported in <productname>Postgres</productname> the UPDATE clause
+ provokes an informational error message.
+ </para>
+ </listitem>
+ </varlistentry>
- </VARIABLELIST>
- </REFSECT2>
+ </variablelist>
+ </para>
+ </refsect2>
- <REFSECT2 ID="R2-SQL-DECLARE-2">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DECLARE-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- SELECT
- </TERM>
- <LISTITEM>
- <PARA>
- The message returned if the SELECT is run successfully.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+SELECT
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The message returned if the SELECT is run successfully.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
- NOTICE
- BlankPortalAssignName: portal "<replaceable class="parameter">cursor</replaceable>" already exists
- </TERM>
- <LISTITEM>
- <PARA>
- This error occurs if cursor "<replaceable class="parameter">cursor</replaceable>" is already declared.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
+ <varlistentry>
+ <term><computeroutput>
+NOTICE
+BlankPortalAssignName: portal "<replaceable class="parameter">cursor</replaceable>" already exists
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This error occurs if <replaceable class="parameter">cursor</replaceable> is already declared.
+ </para>
+ </listitem>
+ </varlistentry>
- <VARLISTENTRY>
- <TERM>
+ <varlistentry>
+ <term><computeroutput>
ERROR: Named portals may only be used in begin/end transaction blocks
- </TERM>
- <LISTITEM>
- <PARA>
-This error occurs if the cursor is not declared within a transaction block.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This error occurs if the cursor is not declared within a transaction block.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-DECLARE-1">
- <REFSECT1INFO>
- <DATE>1998-09-04</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-DECLARE-1">
+ <refsect1info>
+ <date>1998-09-04</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
- DECLARE allows a user to create cursors, which can be used to retrieve
+ </title>
+ <para>
+ <command>DECLARE</command> allows a user to create cursors, which can be used to retrieve
a small number of rows at a time out of a larger query. Cursors can return
data either in text or in binary foramt.
- </PARA>
- <PARA>
+ </para>
+
+ <para>
Normal cursors return data in text format, either ASCII or another
-encoding scheme depending on how the <productname>Postgres</productname>
-backend was built. Since
+ encoding scheme depending on how the <productname>Postgres</productname>
+ backend was built. Since
data is stored natively in binary format, the system must
do a conversion to produce the text format. In addition,
text formats are often larger in size than the corresponding binary format.
Once the information comes back in text form, the client
application may have to convert it to a binary format to
manipulate it anyway.
- </PARA>
- <PARA>
+ </para>
+
+ <para>
BINARY cursors give you back the data in the native binary
representation. So binary cursors will tend to be a
little faster since they suffer less conversion overhead.
</para>
+
<para>
As an example, if a query returns a value of one from an integer column,
-you would get a string of '1' with a default cursor
-whereas with a binary cursor you would get
- a 4-byte value equal to control-A ('^A').
+ you would get a string of '1' with a default cursor
+ whereas with a binary cursor you would get
+ a 4-byte value equal to control-A ('^A').
+
<caution>
<para>
BINARY cursors should be used carefully. User applications such
</para>
</caution>
</para>
- <PARA>
+
+ <para>
However, string representation is architecture-neutral whereas binary
representation can differ between different machine architectures.
Therefore, if your client machine and server machine use different
representations (e.g. "big-endian" versus "little-endian"),
- you will probably not want your data returned in
+ you will probably not want your data returned in
binary format.
-
+
<tip>
<para>
If you intend to display the data in
effort on the client side.
</para>
</tip>
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DECLARE-3">
- <REFSECT2INFO>
- <DATE>1998-09-04</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-DECLARE-3">
+ <refsect2info>
+ <date>1998-09-04</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
Cursors are only available in transactions.
- </PARA>
- <PARA>
+ </para>
+ <para>
<productname>Postgres</productname>
does not have an explicit <command>OPEN cursor</command>
statement; a cursor is considered to be open when it is declared.
-
+
<note>
<para>
In <acronym>SQL92</acronym> cursors are only available in
involving DECLARE and OPEN statements.
</para>
</note>
-
- </PARA>
- </REFSECT2>
+ </para>
+ </refsect2>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-DECLARESTATEMENT-2">
- <TITLE>
+
+ <refsect1 id="R1-SQL-DECLARESTATEMENT-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
To declare a cursor:
- </PARA>
- <ProgramListing>
+
+ <programlisting>
DECLARE liahona CURSOR
FOR SELECT * FROM films;
- </ProgramListing>
- </REFSECT1>
+ </programlisting>
+ </para>
+ </refsect1>
- <REFSECT1 ID="R1-SQL-DECLARESTATEMENT-3">
- <TITLE>
+ <refsect1 id="R1-SQL-DECLARESTATEMENT-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DECLARESTATEMENT-4">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ </para>
+
+ <refsect2 id="R2-SQL-DECLARESTATEMENT-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
<acronym>SQL92</acronym> allows cursors only in embedded <acronym>SQL</acronym>
and in modules. <productname>Postgres</productname> permits cursors to be used
interactively.
</para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-DELETE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-DELETE">
+ <refmeta>
+ <refentrytitle>
DELETE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
DELETE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Deletes rows from a table
- </REFPURPOSE>
-
+ </refpurpose>
+
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
- DELETE FROM <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> [ WHERE <REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE> ]
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-DELETE-1">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+DELETE FROM <replaceable class="PARAMETER">table</replaceable> [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
+ </synopsis>
+
+ <refsect2 id="R2-SQL-DELETE-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">table</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of an existing table.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">condition</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- This is an SQL selection query which returns the rows which
- are to be deleted.
- </PARA>
- <PARA>
- Refer to the SELECT statement for further description
- of the WHERE clause.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-DELETE-2">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">table</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing table.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">condition</replaceable></term>
+ <listitem>
+ <para>
+ This is an SQL selection query which returns the rows which
+ are to be deleted.
+ </para>
+ <para>
+ Refer to the SELECT statement for further description
+ of the WHERE clause.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-DELETE-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue> DELETE <replaceable class="parameter">count</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if items are successfully deleted. The
- <replaceable class="parameter">count</replaceable> is the number
- of rows deleted.
- </PARA>
- <PARA>
- If <replaceable class="parameter">count</replaceable> is 0,
- no rows were deleted.
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+DELETE <replaceable class="parameter">count</replaceable>
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if items are successfully deleted. The
+ <replaceable class="parameter">count</replaceable> is the number
+ of rows deleted.
+ </para>
+ <para>
+ If <replaceable class="parameter">count</replaceable> is 0,
+ no rows were deleted.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-DELETE-1">
- <REFSECT1INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-DELETE-1">
+ <refsect1info>
+ <date>1998-04-15</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
- DELETE removes rows which satisfy the WHERE <replaceable class="parameter">condition</replaceable>,
- from the specified table.
- </PARA>
- <PARA>
- If the <replaceable class="parameter">condition</replaceable> is absent,
+ </title>
+ <para>
+ <command>DELETE</command> removes rows which satisfy the WHERE
+ clause from the specified table.
+ </para>
+ <para>
+ If the <firstterm>condition</firstterm> (WHERE clause) is absent,
the effect is to delete all rows in the table.
The result is a valid, but empty table.
- </PARA>
- <PARA>
+ </para>
+ <para>
You must have write access to the table in order to modify
it, as well as read access to any table whose values are
read in the <replaceable class="parameter">condition</replaceable>.
- </PARA>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-DELETE-2">
- <TITLE>
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-DELETE-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Remove all films but musicals:
- </PARA>
- <ProgramListing>
-DETETE FROM films WHERE kind <> 'Musical';
-
+ <programlisting>
+DELETE FROM films WHERE kind <> 'Musical';
SELECT * FROM films;
code |title |did| date_prod|kind |len
TC901|The King and I |109|1956-08-11|Musical | 02:13
WD101|Bed Knobs and Broomsticks|111| |Musical | 01:57
(3 rows)
- </ProgramListing>
+ </programlisting>
+ </para>
+
<para>
Clear the table <literal>films</literal>:
- </para>
- <programlisting>
+ <programlisting>
DELETE FROM films;
-
SELECT * FROM films;
+
code|title|did|date_prod|kind|len
----+-----+---+---------+----+---
(0 rows)
- </programlisting>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-DELETE-3">
- <TITLE>
+ </programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-DELETE-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DELETE-4">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ </para>
+
+ <refsect2 id="R2-SQL-DELETE-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
- <acronym>SQL92</acronym> allows a positioned DELETE statement:
- </PARA>
-
- <synopsis>
-DELETE FROM <replaceable class="parameter">table</replaceable> WHERE CURRENT OF <replaceable class="parameter">cursor</replaceable>
- </synopsis>
+ </title>
<para>
- where <replaceable class="parameter">cursor</replaceable> identifies an open cursor. Interactive cursors in <productname>Postgres</productname> are read-only.
+ <acronym>SQL92</acronym> allows a positioned DELETE statement:
+
+ <synopsis>
+DELETE FROM <replaceable class="parameter">table</replaceable> WHERE
+ CURRENT OF <replaceable class="parameter">cursor</replaceable>
+ </synopsis>
+
+ where <replaceable class="parameter">cursor</replaceable>
+ identifies an open cursor.
+ Interactive cursors in <productname>Postgres</productname> are read-only.
</para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="APP-DESTROYDB">
-<REFMETA>
-<REFENTRYTITLE>
-<application>destroydb</application>
-</REFENTRYTITLE>
-<REFMISCINFO>Application</REFMISCINFO>
-</REFMETA>
-<REFNAMEDIV>
-<REFNAME>
-<application>destroydb</application>
-</REFNAME>
-<REFPURPOSE>
-Remove an existing <productname>Postgres</productname> database
-</REFPURPOSE>
- </refnamediv>
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-10-02</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
+<refentry id="APP-DESTROYDB">
+ <refmeta>
+ <refentrytitle>
+ <application>destroydb</application>
+ </refentrytitle>
+ <refmiscinfo>Application</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ <application>destroydb</application>
+ </refname>
+ <refpurpose>
+ Remove an existing <productname>Postgres</productname> database
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-10-02</date>
+ </refsynopsisdivinfo>
+ <synopsis>
destroydb [ <replaceable class="parameter">dbname</replaceable> ]
destroydb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
[ -i ] [ <replaceable class="parameter">dbname</replaceable> ]
-</SYNOPSIS>
+ </synopsis>
- <REFSECT2 ID="R2-APP-DESTROYDB-1">
- <REFSECT2INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT2INFO>
- <TITLE>
- Inputs
- </TITLE>
- <PARA>
-
- <variablelist>
- <varlistentry>
- <term>
- -h <replaceable class="parameter">host</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the hostname of the machine on which the
- <application>postmaster</application>
- is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -p <replaceable class="parameter">port</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the Internet TCP/IP port or local Unix domain socket file
- extension on which the <application>postmaster</application>
- is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
- environment variable (if set).
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -i
- </term>
- <listitem>
- <para>
- Run in interactive mode.
- Prompts for confirmation before destroying a database.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="parameter">dbname</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the name of the database to be destroyed. The database
- must be one of the existing <productname>Postgres</productname> databases
- in this installation.
- <replaceable class="parameter">dbname</replaceable>
- defaults to the value of the
- <envar>USER</envar>
- environment variable.
- </para>
- </listitem>
- </varlistentry>
-
- </variablelist>
- </para>
- </refsect2>
+ <refsect2 id="R2-APP-DESTROYDB-1">
+ <refsect2info>
+ <date>1998-10-02</date>
+ </refsect2info>
+ <title>
+ Inputs
+ </title>
+ <para>
- <REFSECT2 ID="R2-APP-DESTROYDB-2">
- <REFSECT2INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT2INFO>
- <TITLE>
- Outputs
- </TITLE>
- <PARA>
- <application>destroydb</application> will remove files from the
- <filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
- data area for the existing database.
-
- <variablelist>
- <varlistentry>
- <term>
- Connection to database 'template1' failed.
- connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
- destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- <application>destroydb</application> could not attach to the
- <application>postmaster</application>
- process on the specified host and port. If you see this message,
- ensure that the <application>postmaster</application>
- is running on the proper host and that you have specified the proper
- port. If your site uses an authentication system, ensure that you
- have obtained the required authentication credentials.
- </para>
- </listitem>
- </varlistentry>
+ <variablelist>
+ <varlistentry>
+ <term>-h <replaceable class="parameter">host</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- Connection to database 'template1' failed.
- FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
- destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- You do not have a valid entry in the relation <literal>pg_shadow</literal>
- and and will not be allowed to access <productname>Postgres</productname>.
- Contact your <productname>Postgres</productname> administrator.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term>-p <replaceable class="parameter">port</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
- destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- You do not have permission to destroy (or create) databases.
- Contact your <productname>Postgres</productname> site administrator.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' does not exist.
- destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- The database to be removed does not have an entry in the
- <literal>pg_database</literal> class.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' is not owned by you.
- destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- You are not the Database Administrator (DBA) for the specified database.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
- </term>
- <listitem>
- <para>
- An internal error occurred in <application>psql</application>
- or in the backend server. Ensure that your site administrator has
- properly installed <productname>Postgres</productname>and initialized the site with
- <application>initdb</application>.
- </para>
- </listitem>
- </varlistentry>
-
- </variablelist>
- </para>
- <note>
- <para>
- <application>destroydb</application> internally runs
- <command>DESTROY DATABASE</command> from <application>psql</application>
- while connected to the <literal>template1</literal> database.
- </para>
- </note>
- </refsect2>
- </refsynopsisdiv>
+ <varlistentry>
+ <term>-i</term>
+ <listitem>
+ <para>
+ Run in interactive mode.
+ Prompts for confirmation before destroying a database.
+ </para>
+ </listitem>
+ </varlistentry>
- <REFSECT1 ID="R1-APP-DESTROYDB-1">
- <REFSECT1INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT1INFO>
- <TITLE>
- Description
- </TITLE>
- <PARA>
- <application>destroydb</application> destroys an existing
- <productname>Postgres</productname> database.
- The person who executes this command must be
- the database administrator, or <acronym>DBA</acronym>,
- or must be the <productname>Postgres</productname> super-user.
- The program runs silently; no confirmation message will be displayed.
- After the database is destroyed, a Unix shell prompt will reappear.
- </para>
- <para>
- All references to
- the database are removed, including the directory containing this
- database and its associated files.
- </para>
- <para>
- <application>destroydb</application> is a shell script that invokes
- <application>psql</application>.
- Hence, a <application>postmaster</application>
- process must be running on the database server host before
- <application>destroydb</application>
- is executed. The
- <envar>PGOPTION</envar>
- and
- <envar>PGREALM</envar>
- environment variables will be passed on to
- <application>psql</application>
- and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
- </para>
- </refsect1>
+ <varlistentry>
+ <term><replaceable class="parameter">dbname</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the name of the database to be destroyed. The database
+ must be one of the existing <productname>Postgres</productname> databases
+ in this installation.
+ <replaceable class="parameter">dbname</replaceable>
+ defaults to the value of the
+ <envar>USER</envar>
+ environment variable.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
- <REFSECT1 ID="R1-APP-DESTROYDB-2">
- <REFSECT1INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT1INFO>
- <TITLE>
- Usage
- </TITLE>
- <PARA>
- To destroy the database <literal>demo</literal>
- using the postmaster on the local host, port 5432:
- <programlisting>
- destroydb demo
- </programlisting>
- </para>
+ <refsect2 id="R2-APP-DESTROYDB-2">
+ <refsect2info>
+ <date>1998-10-02</date>
+ </refsect2info>
+ <title>
+ Outputs
+ </title>
+ <para>
+ <application>destroydb</application> will remove files from the
+ <filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
+ data area for the existing database.
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+Connection to database 'template1' failed.
+connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ <application>destroydb</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+Connection to database 'template1' failed.
+FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>.
+ Contact your <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
+destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You do not have permission to destroy (or create) databases.
+ Contact your <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' does not exist.
+destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The database to be removed does not have an entry in the
+ <literal>pg_database</literal> class.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' is not owned by you.
+destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You are not the Database Administrator (DBA) for the specified database.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. Ensure that your site administrator has
+ properly installed <productname>Postgres</productname>and initialized the site with
+ <application>initdb</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <note>
<para>
- To destroy the database <literal>demo</literal>
- using the postmaster on host eden, port 5000:
- <programlisting>
- destroydb -p 5000 -h eden demo
- </programlisting>
+ <application>destroydb</application> internally runs
+ <command>DESTROY DATABASE</command> from <application>psql</application>
+ while connected to the <literal>template1</literal> database.
</para>
- </refsect1>
-</REFENTRY>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-APP-DESTROYDB-1">
+ <refsect1info>
+ <date>1998-10-02</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
+ <application>destroydb</application> destroys an existing
+ <productname>Postgres</productname> database.
+ The person who executes this command must be
+ the database administrator, or <acronym>DBA</acronym>,
+ or must be the <productname>Postgres</productname> super-user.
+ The program runs silently; no confirmation message will be displayed.
+ After the database is destroyed, a Unix shell prompt will reappear.
+ </para>
+ <para>
+ All references to
+ the database are removed, including the directory containing this
+ database and its associated files.
+ </para>
+ <para>
+ <application>destroydb</application> is a shell script that invokes
+ <application>psql</application>.
+ Hence, a <application>postmaster</application>
+ process must be running on the database server host before
+ <application>destroydb</application>
+ is executed. The
+ <envar>PGOPTION</envar>
+ and
+ <envar>PGREALM</envar>
+ environment variables will be passed on to
+ <application>psql</application>
+ and processed as described in <xref endterm="psql-ref"
+ linkend="app-psql">.
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-APP-DESTROYDB-2">
+ <refsect1info>
+ <date>1998-10-02</date>
+ </refsect1info>
+ <title>
+ Usage
+ </title>
+ <para>
+ To destroy the database <literal>demo</literal>
+ using the postmaster on the local host, port 5432:
+ <programlisting>
+ destroydb demo
+ </programlisting>
+ </para>
+ <para>
+ To destroy the database <literal>demo</literal>
+ using the postmaster on host eden, port 5000:
+ <programlisting>
+ destroydb -p 5000 -h eden demo
+ </programlisting>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:nil
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:"../reference.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:"/usr/lib/sgml/catalog"
+sgml-local-ecat-files:nil
+End:
+-->
-<REFENTRY ID="APP-DESTROYUSER">
-<REFMETA>
-<REFENTRYTITLE>
-<application>destroyuser</application>
-</REFENTRYTITLE>
-<REFMISCINFO>Application</REFMISCINFO>
-</REFMETA>
-<REFNAMEDIV>
-<REFNAME>
-<application>destroyuser</application>
-</REFNAME>
-<REFPURPOSE>
-Destroy a <productname>Postgres</productname> user and associated databases
-</REFPURPOSE>
- </refnamediv>
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-10-02</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
+<refentry id="APP-DESTROYUSER">
+ <refmeta>
+ <refentrytitle>
+ <application>destroyuser</application>
+ </refentrytitle>
+ <refmiscinfo>Application</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ <application>destroyuser</application>
+ </refname>
+ <refpurpose>
+ Destroy a <productname>Postgres</productname> user and associated databases
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-10-02</date>
+ </refsynopsisdivinfo>
+ <synopsis>
destroyuser [ <replaceable class="parameter">username</replaceable> ]
destroyuser [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
[ <replaceable class="parameter">username</replaceable> ]
-</SYNOPSIS>
+ </synopsis>
- <REFSECT2 ID="R2-APP-DESTROYUSER-1">
- <REFSECT2INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT2INFO>
- <TITLE>
- Inputs
- </TITLE>
- <PARA>
-
- <variablelist>
- <varlistentry>
- <term>
- -h <replaceable class="parameter">host</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the hostname of the machine on which the
- <application>postmaster</application>
- is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- -p <replaceable class="parameter">port</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the Internet TCP/IP port or local Unix domain socket file
- extension on which the <application>postmaster</application>
- is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
- environment variable (if set).
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <replaceable class="parameter">username</replaceable>
- </term>
- <listitem>
- <para>
- Specifies the name of the <productname>Postgres</productname> user to be removed.
- This name must exist in the <productname>Postgres</productname> installation.
- You will be prompted for a name if none is specified on the command line.
- </para>
- </listitem>
- </varlistentry>
-
- </variablelist>
- </para>
- </refsect2>
-
- <REFSECT2 ID="R2-APP-DESTROYUSER-2">
- <REFSECT2INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT2INFO>
- <TITLE>
- Outputs
- </TITLE>
- <PARA>
- <application>destroyuser</application> will remove an entry in the
- <literal>pg_user</literal> or <literal>pg_shadow</literal> system table,
- and will remove all databases for which that user is the administrator
- (<acronym>DBA</acronym>).
+ <refsect2 id="R2-APP-DESTROYUSER-1">
+ <refsect2info>
+ <date>1998-10-02</date>
+ </refsect2info>
+ <title>
+ Inputs
+ </title>
+ <para>
- <variablelist>
- <varlistentry>
- <term>
- Connection to database 'template1' failed.
- connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
- destroyuser: database access failed.
- </term>
- <listitem>
- <para>
- <application>destroyuser</application> could not attach to the
- <application>postmaster</application>
- process on the specified host and port. If you see this message,
- ensure that the <application>postmaster</application>
- is running on the proper host and that you have specified the proper
- port. If your site uses an authentication system, ensure that you
- have obtained the required authentication credentials.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- Connection to database 'template1' failed.
- FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
- destroyuser: database access failed.
- </term>
- <listitem>
- <para>
- You do not have a valid entry in the relation <literal>pg_shadow</literal>
- and and will not be allowed to access <productname>Postgres</productname>. Contact your
- <productname>Postgres</productname> administrator.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- destroyuser: <replaceable class="parameter">username</replaceable> cannot delete users.
- </term>
- <listitem>
- <para>
- You do not have permission to delete users; contact your
- <productname>Postgres</productname> site administrator.
- </para>
- </listitem>
- </varlistentry>
+ <variablelist>
+ <varlistentry>
+ <term>-h <replaceable class="parameter">host</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection.
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- destroyuser: user "<replaceable class="parameter">username</replaceable>" already exists
- </term>
- <listitem>
- <para>
- The user to be added already has an entry in the <literal>pg_shadow</literal>
- class.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- database access failed
- </term>
- <listitem>
- <para>
- An internal error occurred in <application>psql</application>
- or in the backend server. Ensure that your site administrator has
- properly installed <productname>Postgres</productname>and initialized the site with
- <application>initdb</application>.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term>-p <replaceable class="parameter">port</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
- <varlistentry>
- <term>
- destroydb on <replaceable class="parameter">dbname</replaceable> failed - exiting
- </term>
- <listitem>
- <para>
- An internal error occurred in <application>psql</application>
- or in the backend server. There was possibly a Unix permissions problem with the
- specified database.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">username</replaceable></term>
+ <listitem>
+ <para>
+ Specifies the name of the <productname>Postgres</productname> user to be removed.
+ This name must exist in the <productname>Postgres</productname> installation.
+ You will be prompted for a name if none is specified on the command line.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
- <varlistentry>
- <term>
- delete of user <replaceable class="parameter">username</replaceable> was UNSUCCESSFUL
- </term>
- <listitem>
- <para>
- An internal error occurred in <application>psql</application>
- or in the backend server.
- </para>
- </listitem>
- </varlistentry>
+ <refsect2 id="R2-APP-DESTROYUSER-2">
+ <refsect2info>
+ <date>1998-10-02</date>
+ </refsect2info>
+ <title>
+ Outputs
+ </title>
+ <para>
+ <application>destroyuser</application> will remove an entry in the
+ <literal>pg_user</literal> or <literal>pg_shadow</literal> system table,
+ and will remove all databases for which that user is the administrator
+ (<acronym>DBA</acronym>).
- </variablelist>
- </para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+Connection to database 'template1' failed.
+connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+destroyuser: database access failed.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ <application>destroyuser</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
- <note>
- <para>
- <application>destroyuser</application> internally runs
- DROP USER from <application>psql</application>
- while connected to the <literal>template1</literal> database.
- </para>
- </note>
- </refsect2>
- </refsynopsisdiv>
-
- <REFSECT1 ID="R1-APP-DESTROYUSER-1">
- <REFSECT1INFO>
- <DATE>1998-10-02</DATE>
- </REFSECT1INFO>
- <TITLE>
- Description
- </TITLE>
- <PARA>
- <application>destroyuser</application> removes an existing
- <productname>Postgres</productname> user
- and the databases for which that user
- is database administrator.
- Only users with <literal>usesuper</literal> set in
- the <literal>pg_shadow</literal> class can destroy
- <productname>Postgres</productname> users. As shipped,
- the user <literal>postgres</literal> can remove users.
- </para>
- <para>
- <application>destroyuser</application> is a shell script that invokes
- <application>psql</application>.
- Hence, a <application>postmaster</application>
- process must be running on the database server host before
- <application>destroyuser</application> is executed.
- The
- <envar>PGOPTION</envar>
- and
- <envar>PGREALM</envar>
- environment variables will be passed on to
- <application>psql</application>
- and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
- </para>
+ <varlistentry>
+ <term><computeroutput>
+Connection to database 'template1' failed.
+FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+destroyuser: database access failed.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>. Contact your
+ <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+destroyuser: <replaceable class="parameter">username</replaceable> cannot delete users.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ You do not have permission to delete users; contact your
+ <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+destroyuser: user "<replaceable class="parameter">username</replaceable>" already exists
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The user to be added already has an entry in the
+ <literal>pg_shadow</literal> class.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+database access failed
+ </computeroutput></term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. Ensure that your site administrator has
+ properly installed <productname>Postgres</productname>and initialized the site with
+ <application>initdb</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+destroydb on <replaceable class="parameter">dbname</replaceable> failed - exiting
+ </computeroutput></term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. There was possibly a Unix permissions problem with the
+ specified database.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>
+delete of user <replaceable class="parameter">username</replaceable> was UNSUCCESSFUL
+ </computeroutput></term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+
+ <note>
<para>
- Once invoked, <application>destroyuser</application>
- will warn you about the databases that will be destroyed in the
- process and permit you to abort the removal of the user if desired.
+ <application>destroyuser</application> internally runs
+ <command>DROP USER</command> from <application>psql</application>
+ while connected to the <literal>template1</literal> database.
</para>
- </refsect1>
-</REFENTRY>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-APP-DESTROYUSER-1">
+ <refsect1info>
+ <date>1998-10-02</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
+ <application>destroyuser</application> removes an existing
+ <productname>Postgres</productname> user
+ and the databases for which that user
+ is database administrator.
+ Only users with <literal>usesuper</literal> set in
+ the <literal>pg_shadow</literal> class can destroy
+ <productname>Postgres</productname> users. As shipped,
+ the user <literal>postgres</literal> can remove users.
+ </para>
+ <para>
+ <application>destroyuser</application> is a shell script that invokes
+ <application>psql</application>.
+ Hence, a <application>postmaster</application>
+ process must be running on the database server host before
+ <application>destroyuser</application> is executed.
+ The
+ <envar>PGOPTION</envar>
+ and
+ <envar>PGREALM</envar>
+ environment variables will be passed on to
+ <application>psql</application>
+ and processed as described in <xref endterm="psql-ref"
+ linkend="app-psql">.
+ </para>
+ <para>
+ Once invoked, <application>destroyuser</application>
+ will warn you about the databases that will be destroyed in the
+ process and permit you to abort the removal of the user if desired.
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:nil
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:"../reference.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:"/usr/lib/sgml/catalog"
+sgml-local-ecat-files:nil
+End:
+-->
-<REFENTRY ID="SQL-DROPAGGREGATE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-DROPAGGREGATE">
+ <refmeta>
+ <refentrytitle>
DROP AGGREGATE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
DROP AGGREGATE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Removes the definition of an aggregate function
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-DROP AGGREGATE <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE>
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-DROPAGGREGATE-1">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+DROP AGGREGATE <replaceable class="PARAMETER">name</replaceable> <replaceable class="PARAMETER">type</replaceable>
+ </synopsis>
+
+ <refsect2 id="R2-SQL-DROPAGGREGATE-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of an existing aggregate function.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">type</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The type of an existing aggregate function.
- (Refer to the <citetitle>PostgreSQL User's Guide</citetitle> for
- further information about data types).
- <comment>This should become a cross-reference rather than a
- hard-coded chapter number</comment>
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-DROPAGGREGATE-2">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing aggregate function.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">type</replaceable></term>
+ <listitem>
+ <para>
+ The type of an existing aggregate function.
+ (Refer to the <citetitle>PostgreSQL User's Guide</citetitle> for
+ further information about data types).
+ <comment>This should become a cross-reference rather than a
+ hard-coded chapter number</comment>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-DROPAGGREGATE-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>DROP</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the command is successful.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>WARN RemoveAggregate: aggregate '<replaceable class="parameter">name</replaceable>' for '<replaceable class="parameter">type</replaceable>' does not exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message occurs if the aggregate function specified does not
- exist in the database.
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+DROP
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the command is successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+WARN RemoveAggregate: aggregate '<replaceable class="parameter">agg</replaceable>' for '<replaceable class="parameter">type</replaceable>' does not exist
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message occurs if the aggregate function specified does not
+ exist in the database.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-DROPAGGREGATE-1">
- <REFSECT1INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-DROPAGGREGATE-1">
+ <refsect1info>
+ <date>1998-04-15</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>DROP AGGREGATE</command> will remove all references to an existing
aggregate definition. To execute this command the current
user must be the owner of the aggregate.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DROPAGGREGATE-3">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-DROPAGGREGATE-3">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
The <command>DROP AGGREGATE</command> statement is a
-<productname>Postgres</productname>
+ <productname>Postgres</productname>
language extension.
- </PARA>
- <PARA>
+ </para>
+ <para>
Refer to the <command>CREATE AGGREGATE</command> statement to
create aggregate functions.
- </PARA>
- </REFSECT2>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-DROPAGGREGATE-2">
- <TITLE>
+ </para>
+ </refsect2>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-DROPAGGREGATE-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
To remove the <literal>myavg</literal> aggregate for type
<literal>int4</literal>:
- </PARA>
- <ProgramListing>
+ </para>
+ <programlisting>
DROP AGGREGATE myavg int4;
- </ProgramListing>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-DROPAGGREGATE-3">
- <TITLE>
+ </programlisting>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-DROPAGGREGATE-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DROPAGGREGATE-4">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ </para>
+
+ <refsect2 id="R2-SQL-DROPAGGREGATE-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
- There is no DROP AGGREGATE statement in <acronym>SQL92</acronym>.
- </PARA>
+ </title>
+ <para>
+ There is no DROP AGGREGATE statement in <acronym>SQL92</acronym>.
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-DROPDATABASE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-DROPDATABASE">
+ <refmeta>
+ <refentrytitle>
DROP DATABASE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
DROP DATABASE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Destroys an existing database
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-DROP DATABASE <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE>
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-DROPDATABASE-1">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+DROP DATABASE <replaceable class="PARAMETER">name</replaceable>
+ </synopsis>
+
+ <refsect2 id="R2-SQL-DROPDATABASE-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue><REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of an existing database to remove.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-DROPDATABASE-2">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing database to remove.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-DROPDATABASE-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>DESTROYDB</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message is returned if the command is successful.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>WARN: destroydb: database "<replaceable class="parameter">name</replaceable>" does not exist.</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message occurs if the specified database does not exist.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: destroydb cannot be executed on an open database</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message occurs if the specified database does not exist.
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+DESTROYDB
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message is returned if the command is successful.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+WARN: destroydb: database "<replaceable class="parameter">name</replaceable>" does not exist.
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message occurs if the specified database does not exist.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ <varlistentry>
+ <term><computeroutput>
+ ERROR: destroydb cannot be executed on an open database
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message occurs if the specified database does not exist.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
+ </refsect2>
+ </refsynopsisdiv>
- <REFSECT1 ID="R1-SQL-DROPDATABASE-1">
- <REFSECT1INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT1INFO>
- <TITLE>
+ <refsect1 id="R1-SQL-DROPDATABASE-1">
+ <refsect1info>
+ <date>1998-04-15</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>DROP DATABASE</command> removes the catalog entries for an existing
database and deletes the directory containing the data.
It can only be executed by the database administrator
(See the <command>CREATE DATABASE</command> command for details).
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DROPDATABASE-3">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-DROPDATABASE-3">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
+ </title>
<para>
- DROP DATABASE statement is a <productname>Postgres</productname>
- language extension.
+ <command>DROP DATABASE</command> statement is a <productname>Postgres</productname>
+ language extension.
<tip>
<para>
This query cannot be executed while connected to the target
-database. It is usually preferable to use the
- <command>destroydb</command> script instead.
+ database. It is usually preferable to use the
+ <command>destroydb</command> script instead.
</para>
</tip>
-
</para>
+
<para>
Refer to the <command>CREATE DATABASE</command> statement for
information on how to create a database.
</para>
</refsect2>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-DROPDATABASE-3">
- <TITLE>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-DROPDATABASE-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
+ </title>
+ <para>
+ </para>
- <REFSECT2 ID="R2-SQL-DROPDATABASE-4">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DROPDATABASE-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
- There is no <command>DROP DATABASE</command> in <acronym>SQL92</acronym>.
- </PARA>
+ </title>
+ <para>
+ There is no <command>DROP DATABASE</command> in <acronym>SQL92</acronym>.
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-DROPFUNCTION">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-DROPFUNCTION">
+ <refmeta>
+ <refentrytitle>
DROP FUNCTION
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
DROP FUNCTION
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Removes a user-defined C function
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
DROP FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">type</replaceable> [, ...] ] )
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-DROPFUNCTION-1">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </synopsis>
+
+ <refsect2 id="R2-SQL-DROPFUNCTION-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter"> name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of an existing function.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">type</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The type of function parameters.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-DROPFUNCTION-2">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter"> name</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing function.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">type</replaceable></term>
+ <listitem>
+ <para>
+ The type of function parameters.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-DROPFUNCTION-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>DROP</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the command completes successfully.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>WARN RemoveFunction: Function "<replaceable class="parameter">name</replaceable>" ("<replaceable class="parameter">types</replaceable>") does not exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message is given if the function specified does not
-exist in the current database.
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+DROP
+ </computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the command completes successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+WARN RemoveFunction: Function "<replaceable class="parameter">name</replaceable>" ("<replaceable class="parameter">types</replaceable>") does not exist
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message is given if the function specified does not
+ exist in the current database.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-DROPFUNCTION-1">
- <REFSECT1INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-DROPFUNCTION-1">
+ <refsect1info>
+ <date>1998-04-15</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
DROP FUNCTION will remove references to an existing C
function. To execute this command the user must be the
owner of the function. The input argument types to the
function must be specified, as only the function with the
given name and argument types will be removed.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DROPFUNCTION-3">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-DROPFUNCTION-3">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
- Refer to <citerefentry>
-<refentrytitle>
-CREATE FUNCTION
-</refentrytitle>
- </citerefentry>
- to create aggregate functions.
- </PARA>
- </REFSECT2>
+ </title>
+ <para>
+ Refer to <command>CREATE FUNCTION</command>
+ to create aggregate functions.
+ </para>
+ </refsect2>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-DROPFUNCTION-2">
- <TITLE>
+
+ <refsect1 id="R1-SQL-DROPFUNCTION-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
This command removes the square root function:
- </PARA>
- <ProgramListing>
+
+ <programlisting>
DROP FUNCTION sqrt(int4);
- </ProgramListing>
- </REFSECT1>
+ </programlisting>
+ </para>
+ </refsect1>
- <REFSECT1 ID="R1-SQL-DROPFUNCTION-3">
- <TITLE>
+ <refsect1 id="R1-SQL-DROPFUNCTION-3">
+ <title>
Bugs
- </TITLE>
- <PARA>
+ </title>
+ <para>
No checks are made to ensure that types, operators or access
methods that rely on the function have been removed first.
- </PARA>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-DROPFUNCTION-4">
- <TITLE>
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-DROPFUNCTION-4">
+ <title>
Compatibility
- </TITLE>
- <PARA>
-DROP FUNCTION is a <productname>Postgres</productname> language extension.
- </PARA>
+ </title>
+ <para>
+ DROP FUNCTION is a <productname>Postgres</productname> language extension.
+ </para>
- <REFSECT2 ID="R2-SQL-DROPFUNCTION-4">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DROPFUNCTION-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
SQL/PSM
- </TITLE>
- <PARA>
-SQL/PSM is a proposed standard to enable function extensibility.
-The SQL/PSM DROP FUNCTION statement has the following syntax:
+ </title>
+ <para>
+ SQL/PSM is a proposed standard to enable function extensibility.
+ The SQL/PSM DROP FUNCTION statement has the following syntax:
<programlisting>
-DROP [ SPECIFIC ] FUNCTION <replaceable class="parameter">name</replaceable> { RESTRICT | CASCADE }</programlisting>
- </PARA>
+DROP [ SPECIFIC ] FUNCTION <replaceable class="parameter">name</replaceable> { RESTRICT | CASCADE }
+ </programlisting>
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-DROPINDEX">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-DROPINDEX">
+ <refmeta>
+ <refentrytitle>
DROP INDEX
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
DROP INDEX
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Removes an index from a database
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-DROP INDEX <REPLACEABLE CLASS="PARAMETER">index_name</REPLACEABLE>
- </SYNOPSIS>
-
- <REFSECT2 ID="R2-SQL-DROPINDEX-1">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+DROP INDEX <replaceable class="PARAMETER">index_name</replaceable>
+ </synopsis>
+
+ <refsect2 id="R2-SQL-DROPINDEX-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue><REPLACEABLE CLASS="PARAMETER">index_name</REPLACEABLE></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of the index to remove.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-DROPINDEX-2">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">index_name</replaceable></term>
+ <listitem>
+ <para>
+ The name of the index to remove.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-DROPINDEX-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>DROP</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The message returned if the index is successfully dropped.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: index "<REPLACEABLE CLASS="PARAMETER">index_name</REPLACEABLE>" nonexistent</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message occurs if <REPLACEABLE CLASS="PARAMETER">index_name</REPLACEABLE>
- is not an index in the database.
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+DROP
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The message returned if the index is successfully dropped.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: index "<replaceable class="PARAMETER">index_name</replaceable>" nonexistent
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message occurs if <replaceable class="PARAMETER">index_name</replaceable>
+ is not an index in the database.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
+ </refsect2>
+ </refsynopsisdiv>
- <REFSECT1 ID="R1-SQL-DROPINDEX-1">
- <REFSECT1INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT1INFO>
- <TITLE>
+ <refsect1 id="R1-SQL-DROPINDEX-1">
+ <refsect1info>
+ <date>1998-04-15</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>DROP INDEX</command> drops an existing index from the database
system. To execute this command you must be the owner of
the index.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DROPINDEX-3">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </para>
+
+ <refsect2 id="R2-SQL-DROPINDEX-3">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>DROP INDEX</command> is a <productname>Postgres</productname>
- language extension.
- </PARA>
- <PARA>
+ language extension.
+ </para>
+ <para>
Refer to the <command>CREATE INDEX</command> statement for
information on how to create indexes.
- </PARA>
- </REFSECT2>
+ </para>
+ </refsect2>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-DROPINDEX-2">
- <TITLE>
+
+ <refsect1 id="R1-SQL-DROPINDEX-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
This command will remove the <literal>title_idx</literal> index:
- </PARA>
- <ProgramListing>
-DROP INDEX title_idx;
- </ProgramListing>
- </REFSECT1>
-
- <REFSECT1 ID="R1-SQL-DROPINDEX-3">
- <TITLE>
+
+ <programlisting>
+ DROP INDEX title_idx;
+ </programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1 id="R1-SQL-DROPINDEX-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DROPINDEX-4">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ </para>
+
+ <refsect2 id="R2-SQL-DROPINDEX-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
-<acronym>SQL92</acronym> defines commands by which to access
- a generic relational database.
-Indexes are an implementation-dependent feature and hence
-there are no index-specific commands or definitions in the
-<acronym>SQL92</acronym> language.
- </PARA>
+ </title>
+ <para>
+ <acronym>SQL92</acronym> defines commands by which to access
+ a generic relational database.
+ Indexes are an implementation-dependent feature and hence
+ there are no index-specific commands or definitions in the
+ <acronym>SQL92</acronym> language.
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-DROPLANGUAGE">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-DROPLANGUAGE">
+ <refmeta>
+ <refentrytitle>
DROP LANGUAGE
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
DROP LANGUAGE
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Removes a user-defined procedural language
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-DROP PROCEDURAL LANGUAGE '<REPLACEABLE CLASS="PARAMETER">langname</REPLACEABLE>'
- </SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-04-15</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+DROP PROCEDURAL LANGUAGE '<replaceable class="PARAMETER">name</replaceable>'
+ </synopsis>
- <REFSECT2 ID="R2-SQL-DROPLANGUAGE-1">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DROPLANGUAGE-1">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER">langname</REPLACEABLE>
- </TERM>
- <LISTITEM>
- <PARA>
- The name of an existing language.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
+ </title>
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing procedural language.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
- <REFSECT2 ID="R2-SQL-DROPLANGUAGE-2">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DROPLANGUAGE-2">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>DROP</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message is returned if the language is successfully dropped.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>
- ERROR: Language "<replaceable class="parameter">langname</replaceable>" doesn't exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message occurs if the language
- "<replaceable class="parameter">langname</replaceable>" is
- not found.
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+DROP
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message is returned if the language is successfully dropped.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: Language "<replaceable class="parameter">name</replaceable>" doesn't exist
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message occurs if a language called
+ <replaceable class="parameter">name</replaceable> is
+ not found in the database.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
+ </refsect2>
+ </refsynopsisdiv>
- <REFSECT1 ID="R1-SQL-DROPLANGUAGE-1">
- <REFSECT1INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT1INFO>
- <TITLE>
+ <refsect1 id="R1-SQL-DROPLANGUAGE-1">
+ <refsect1info>
+ <date>1998-04-15</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
+ </title>
+ <para>
<command>DROP PROCEDURAL LANGUAGE</command> will remove the definition
- of the previously registered procedural language having the name
- '<replaceable class="parameter">langname</replaceable>'.
- </PARA>
+ of the previously registered procedural language called
+ <replaceable class="parameter">name</replaceable>.
+ </para>
- <REFSECT2 ID="R2-SQL-DROPLANGUAGE-3">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DROPLANGUAGE-3">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
The <command>DROP PROCEDURAL LANGUAGE</command> statement is
a <productname>Postgres</productname> language extension.
- </PARA>
- <PARA>
+ </para>
+ <para>
Refer to <command>CREATE PROCEDURAL LANGUAGE</command>
for information on how to create procedural languages.
- </PARA>
+ </para>
</refsect2>
- <REFSECT2 ID="R2-SQL-DROPLANGUAGE-4">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DROPLANGUAGE-4">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
Bugs
- </TITLE>
- <PARA>
+ </title>
+ <para>
No checks are made if functions or trigger procedures registered
in this language still exist. To re-enable them without having
to drop and recreate all the functions, the pg_proc's prolang
attribute of the functions must be adjusted to the new object
ID of the recreated pg_language entry for the PL.
- </PARA>
- </REFSECT2>
+ </para>
+ </refsect2>
</refsect1>
- <REFSECT1 ID="R1-SQL-DROPLANGUAGE-2">
- <TITLE>
+ <refsect1 id="R1-SQL-DROPLANGUAGE-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
This command removes the PL/Sample language:
- </PARA>
- <ProgramListing>
-DROP PROCEDURAL LANGUAGE 'plsample'
- </ProgramListing>
- </REFSECT1>
+
+ <programlisting>
+DROP PROCEDURAL LANGUAGE 'plsample';
+ </programlisting>
+ </para>
+ </refsect1>
- <REFSECT1 ID="R1-SQL-DROPLANGUAGE-3">
- <TITLE>
+ <refsect1 id="R1-SQL-DROPLANGUAGE-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
+ </title>
+ <para>
+ </para>
- <REFSECT2 ID="R2-SQL-DROPLANGUAGE-5">
- <REFSECT2INFO>
- <DATE>1998-04-15</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DROPLANGUAGE-5">
+ <refsect2info>
+ <date>1998-04-15</date>
+ </refsect2info>
+ <title>
SQL92
- </TITLE>
- <PARA>
+ </title>
+ <para>
There is no <command>DROP PROCEDURAL LANGUAGE</command> in
-<acronym>SQL92</acronym>.
- </PARA>
+ <acronym>SQL92</acronym>.
+ </para>
</refsect2>
</refsect1>
-</REFENTRY>
-
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
-sgml-omittag:t
+sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
-<REFENTRY ID="SQL-DROPOPERATOR">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-DROPOPERATOR">
+ <refmeta>
+ <refentrytitle>
DROP OPERATOR
- </REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
- </REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ </refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+ <refnamediv>
+ <refname>
DROP OPERATOR
- </REFNAME>
- <REFPURPOSE>
+ </refname>
+ <refpurpose>
Removes an operator from the database
- </REFPURPOSE>
+ </refpurpose>
</refnamediv>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-22</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-DROP OPERATOR <REPLACEABLE CLASS="PARAMETER">id</REPLACEABLE> ( <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE> | NONE [,...] )
- </SYNOPSIS>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-22</date>
+ </refsynopsisdivinfo>
+ <synopsis>
+DROP OPERATOR <replaceable class="PARAMETER">id</replaceable> ( <replaceable class="PARAMETER">type</replaceable> | NONE [,...] )
+ </synopsis>
- <REFSECT2 ID="R2-SQL-DROPOPERATOR-1">
- <REFSECT2INFO>
- <DATE>1998-09-22</DATE>
- </REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-DROPOPERATOR-1">
+ <refsect2info>
+ <date>1998-09-22</date>
+ </refsect2info>
+ <title>
Inputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">id</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The identifier of an existing operator.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">type</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The type of function parameters.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT2>
-
- <REFSECT2 ID="R2-SQL-DROPOPERATOR-2">
- <REFSECT2INFO>
- <DATE>1998-09-22</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">id</replaceable></term>
+ <listitem>
+ <para>
+ The identifier of an existing operator.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">type</replaceable></term>
+ <listitem>
+ <para>
+ The type of function parameters.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <refsect2 id="R2-SQL-DROPOPERATOR-2">
+ <refsect2info>
+ <date>1998-09-22</date>
+ </refsect2info>
+ <title>
Outputs
- </TITLE>
- <PARA>
+ </title>
+ <para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>DROP</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The message returned if the command is successful.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: RemoveOperator: binary operator '<REPLACEABLE CLASS="PARAMETER">id</REPLACEABLE>' taking '<REPLACEABLE CLASS="PARAMETER">type1</REPLACEABLE>' and '<REPLACEABLE CLASS="PARAMETER">type2</REPLACEABLE>' does not exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message occurs if the specified binary operator does not exist.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: RemoveOperator: left unary operator '<REPLACEABLE CLASS="PARAMETER">id</REPLACEABLE>' taking '<REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE>' does not exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message occurs if the specified left unary operator
- specified does not exist.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: RemoveOperator: right unary operator '<REPLACEABLE CLASS="PARAMETER">id</REPLACEABLE>' taking '<REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE>' does not exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This message occurs if the specified right unary operator
- specified does not exist.
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>
+DROP
+ </computeroutput></term>
+ <listitem>
+ <para>
+ The message returned if the command is successful.
</para>
</listitem>
</varlistentry>
- </VARIABLELIST>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: RemoveOperator: binary operator '<replaceable class="PARAMETER">oper</replaceable>' taking '<replaceable class="PARAMETER">type</replaceable>' and '<replaceable class="PARAMETER">type2</replaceable>' does not exist
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message occurs if the specified binary operator does not exist.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: RemoveOperator: left unary operator '<replaceable class="PARAMETER">oper</replaceable>' taking '<replaceable class="PARAMETER">type</replaceable>' does not exist
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message occurs if the specified left unary operator
+ specified does not exist.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><computeroutput>
+ERROR: RemoveOperator: right unary operator '<replaceable class="PARAMETER">oper</replaceable>' taking '<replaceable class="PARAMETER">type</replaceable>' does not exist
+ </computeroutput></term>
+ <listitem>
+ <para>
+ This message occurs if the specified right unary operator
+ specified does not exist.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
- <REFSECT1 ID="R1-SQL-DROPOPERATOR-1">
- <REFSECT1INFO>
- <DATE>1998-09-22</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <refsect1 id="R1-SQL-DROPOPERATOR-1">
+ <refsect1info>
+ <date>1998-09-22</date>
+ </refsect1info>
+ <title>
Description
- </TITLE>
- <PARA>
- The DROP OPERATOR statement drops an existing operator from the
+ </title>
+ <para>
+ <command>DROP OPERATOR</command> drops an existing operator from the
database.
To execute this command you must be the owner of the operator.
- </PARA>
- <PARA>
+ </para>
+ <para>
The left or right type of a left or right unary
- operator, respectively, may be specified as NONE.
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DROPOPERATOR-3">
- <REFSECT2INFO>
- <DATE>1998-09-22</DATE>
- </REFSECT2INFO>
- <TITLE>
+ operator, respectively, may be specified as <literal>NONE</literal>.
+ </para>
+
+ <refsect2 id="R2-SQL-DROPOPERATOR-3">
+ <refsect2info>
+ <date>1998-09-22</date>
+ </refsect2info>
+ <title>
Notes
- </TITLE>
- <PARA>
+ </title>
+ <para>
The <command>DROP OPERATOR</command> statement is a
-<productname>Postgres</productname>
+ <productname>Postgres</productname>
language extension.
- </PARA>
- <PARA>
+ </para>
+ <para>
Refer to <command>CREATE OPERATOR</command> for
information on how to create operators.
- </PARA>
- <PARA>
+ </para>
+ <para>
It is the user's responsibility to remove any access methods and
operator classes that rely on the deleted operator.
- </PARA>
- </REFSECT2>
+ </para>
+ </refsect2>
</refsect1>
-
- <REFSECT1 ID="R1-SQL-DROPOPERATOR-2">
- <TITLE>
+
+ <refsect1 id="R1-SQL-DROPOPERATOR-2">
+ <title>
Usage
- </TITLE>
- <PARA>
+ </title>
+ <para>
Remove power operator <literal>a^n</literal> for <literal>int4</literal>:
- </PARA>
- <ProgramListing>
+
+ <programlisting>
DROP OPERATOR ^ (int4, int4);
- </ProgramListing>
- <PARA>
- Remove left unary operator <literal>!a</literal> for booleans:
- </PARA>
- <ProgramListing>
+ </programlisting>
+ </para>
+ <para>
+ Remove left unary negation operator (<literal>b !</literal>) for booleans:
+ <programlisting>
DROP OPERATOR ! (none, bool);
- </ProgramListing>
- <PARA>
- Remove right unary factorial operator <literal>a!</literal> for
+ </programlisting>
+ </para>
+ <para>
+ Remove right unary factorial operator (<literal>! i</literal>) for
<literal>int4</literal>:
- </PARA>
- <ProgramListing>
+ <programlisting>
DROP OPERATOR ! (int4, none);
- </ProgramListing>
- </REFSECT1>
+ </programlisting>
+ </para>
+ </refsect1>
- <REFSECT1 ID="R1-SQL-DROPOPERATOR-3">
- <TITLE>
+ <refsect1 id="R1-SQL-DROPOPERATOR-3">
+ <title>
Compatibility
- </TITLE>
- <PARA>
- </PARA>
-
- <REFSECT2 ID="R2-SQL-DROPOPERATOR-4">
- <REFSECT2INFO>
- <DATE>1998-09-22</DATE>
- </REFSECT2INFO>
- <TITLE>
+ </