-<Chapter>
-<Title>Commands</Title>
+<!-- allfiles.sgml
+-
+- Complete list of usable sgml source files in this directory.
+-
+- -->
-<Para>
-</Para>
+<!entity intro-ref system "intro-ref.sgml">
+<!entity commands system "commands.sgml">
-&alterTable;
-&alterUser;
-&begin;
-&close;
-&cluster;
-&commit;
-©
-&createAggregate;
-&createDatabase;
-&createFunction;
-&createIndex;
-&createLanguage;
-&createOperator;
-&createRule;
-&createSequence;
-&createTable;
-&dropFunction;
-&select;
+<!-- these will go into the "operators" reference chapter -->
+<!entity all system "all.sgml">
+<!entity any system "any.sgml">
+<!entity between system "between.sgml">
+<!entity in system "in.sgml">
+<!entity like system "like.sgml">
-</Chapter>
+<!-- these will go into the "functions" reference chapter -->
+<!entity avg system "avg.sgml">
+<!entity cast system "cast.sgml">
+<!entity charLength system "char_length.sgml">
+<!entity count system "count.sgml">
+<!entity currentDate system "current_date.sgml">
+<!entity currentTime system "current_time.sgml">
+<!entity currentTimestamp system "current_timestamp.sgml">
+<!entity currentUser system "current_user.sgml">
+<!entity exists system "exists.sgml">
+<!entity extract system "extract.sgml">
+<!entity initcap system "initcap.sgml">
+<!entity lower system "lower.sgml">
+<!entity lpad system "lpad.sgml">
+<!entity max system "max.sgml">
+<!entity min system "min.sgml">
+<!entity position system "position.sgml">
+<!entity rpad system "rpad.sgml">
+<!entity substring system "substring.sgml">
+<!entity sum system "sum.sgml">
+<!entity translate system "translate.sgml">
+<!entity trim system "trim.sgml">
+<!entity upper system "upper.sgml">
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-omittag:t
-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:
+<!-- these are folded into create_table.sgml
+<!entity check system "check.sgml">
+<!entity constraints system "constraint.sgml">
+<!entity default system "default.sgml">
+<!entity notNull system "not_null.sgml">
+<!entity primaryKey system "primary_key.sgml">
+<!entity unique system "unique.sgml">
-->
+
+<!-- these are folded into select.sgml
+<!entity groupBy system "group_by.sgml">
+<!entity having system "having.sgml">
+<!entity orderBy system "order_by.sgml">
+<!entity union system "union.sgml">
+-->
+
+<!-- these are in the "commands" reference chapter -->
+<!entity alterTable system "alter_table.sgml">
+<!entity alterUser system "alter_user.sgml">
+<!entity begin system "begin.sgml">
+<!entity close system "close.sgml">
+<!entity cluster system "cluster.sgml">
+<!entity commit system "commit.sgml">
+<!entity copy system "copy.sgml">
+<!entity createAggregate system "create_aggregate.sgml">
+<!entity createDatabase system "create_database.sgml">
+<!entity createFunction system "create_function.sgml">
+<!entity createIndex system "create_index.sgml">
+<!entity createLanguage system "create_language.sgml">
+<!entity createOperator system "create_operator.sgml">
+<!entity createRule system "create_rule.sgml">
+<!entity createSequence system "create_sequence.sgml">
+<!entity createTable system "create_table.sgml">
+<!entity createTrigger system "create_trigger.sgml">
+<!entity createType system "create_type.sgml">
+<!entity createUser system "create_user.sgml">
+<!entity createView system "create_view.sgml">
+<!entity declare system "declare.sgml">
+<!entity delete system "delete.sgml">
+<!entity dropAggregate system "drop_aggregate.sgml">
+<!entity dropDatabase system "drop_database.sgml">
+<!entity dropFunction system "drop_function.sgml">
+<!entity dropIndex system "drop_index.sgml">
+<!entity dropLanguage system "drop_language.sgml">
+<!entity dropOperator system "drop_operator.sgml">
+<!entity dropRule system "drop_rule.sgml">
+<!entity dropSequence system "drop_sequence.sgml">
+<!entity dropTable system "drop_table.sgml">
+<!entity dropTrigger system "drop_trigger.sgml">
+<!entity dropType system "drop_type.sgml">
+<!entity dropUser system "drop_user.sgml">
+<!entity dropView system "drop_view.sgml">
+<!entity explain system "explain.sgml">
+<!entity fetch system "fetch.sgml">
+<!entity grant system "grant.sgml">
+<!entity insert system "insert.sgml">
+<!entity listen system "listen.sgml">
+<!entity load system "load.sgml">
+<!entity lock system "lock.sgml">
+<!entity move system "move.sgml">
+<!entity notify system "notify.sgml">
+<!entity reset system "reset.sgml">
+<!entity revoke system "revoke.sgml">
+<!entity rollback system "rollback.sgml">
+<!entity select system "select.sgml">
+<!entity set system "set.sgml">
+<!entity show system "show.sgml">
+<!entity update system "update.sgml">
+<!entity vacuum system "vacuum.sgml">
--- /dev/null
+<REFENTRY ID="SQL-CREATETRIGGER-1">
+ <REFMETA>
+ <REFENTRYTITLE>
+ CREATE TRIGGER
+ </REFENTRYTITLE>
+ <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
+ </REFMETA>
+ <REFNAMEDIV>
+ <REFNAME>
+ CREATE TRIGGER
+ </REFNAME>
+ <REFPURPOSE>
+ CREATE TRIGGER - creates a new trigger.
+ </REFPURPOSE>
+ <REFSYNOPSISDIV>
+ <REFSYNOPSISDIVINFO>
+ <DATE>1998-04-15</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>
+
+ <REFSECT2 ID="R2-SQL-CREATETRIGGER-1">
+ <REFSECT2INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ </TERM>
+ <LISTITEM>
+ <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>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-CREATETRIGGER-2">
+ <REFSECT2INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>CREATE</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ This message is returned if the trigger is successfully created.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-CREATETRIGGER-1">
+ <REFSECT1INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ CREATE TRIGGER 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>
+ Only the relation owner may create a trigger on this relation.
+ </PARA>
+ <PARA>
+ At release 6.3.2, STATEMENT triggers are not implemented.
+ </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
+ after the operation has been attempted (e.g. after constraints
+ are checked and the INSERT, UPDATE or DELETE has completed). If the
+ trigger fires before the event, the trigger may
+ skip the operation for the current tuple, or change the tuple
+ 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>
+ Refer to the SPI and trigger programming guides for more
+ information.
+ </PARA>
+ <REFSECT2 ID="R2-SQL-CREATETRIGGER-3">
+ <REFSECT2INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ CREATE TRIGGER statement is a PostgreSQL language extension.
+ </PARA>
+ <PARA>
+ Refer to the DROP TRIGGER statement for information on how to
+ remove triggers.
+ </PARA>
+
+ </REFSECT2>
+
+ <REFSECT1 ID="R1-SQL-CREATETRIGGER-2">
+ <TITLE>
+ Usage
+ </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>
+ 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>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-CREATETRIGGER-4">
+ <REFSECT2INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no CREATE TRIGGER statement in SQL92.
+ </PARA>
+ <PARA>
+ The second example above may also be done by using a FOREIGN KEY
+ constraint as in:
+ </PARA>
+ <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>
+ However, foreign keys are not yet implemented at version 6.3.2 of
+ PostgreSQL.
+ </PARA>
+</REFENTRY>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+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:
+-->
\ No newline at end of file
--- /dev/null
+<REFENTRY ID="SQL-CREATETYPE-1">
+ <REFMETA>
+ <REFENTRYTITLE>
+ CREATE TYPE
+ </REFENTRYTITLE>
+ <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
+ </REFMETA>
+ <REFNAMEDIV>
+ <REFNAME>
+ CREATE TYPE
+ </REFNAME>
+ <REFPURPOSE>
+ CREATE TYPE - defines a new base data type.
+ </REFPURPOSE>
+ <REFSYNOPSISDIV>
+ <REFSYNOPSISDIVINFO>
+ <DATE>1998-04-15</DATE>
+ </REFSYNOPSISDIVINFO>
+ <SYNOPSIS>
+ CREATE TYPE <replaceable class="parameter">typename</replaceable> (
+ INTERNALLENGTH = (<replaceable class="parameter">internallength</replaceable> | VARIABLE)
+ [, EXTERNALLENGTH = (<replaceable class="parameter">externallength</replaceable> | VARIABLE) ]
+<comment>
+Why are parentheses required around the length parameters?
+</comment>
+ , INPUT = <replaceable class="parameter">input_function</replaceable>
+ , OUTPUT = <replaceable class="parameter">output_function</replaceable>
+ [, ELEMENT = <replaceable class="parameter">element</replaceable>]
+ [, DELIMITER = <replaceable class="parameter">delimiter</replaceable>]
+ [, DEFAULT = "<replaceable class="parameter">default</replaceable>" ]
+ [, SEND = <replaceable class="parameter">send_function</replaceable> ]
+ [, RECEIVE = <replaceable class="parameter">receive_function</replaceable> ]
+ [, PASSEDBYVALUE])
+ </SYNOPSIS>
+
+ <REFSECT2 ID="R2-SQL-CREATETYPE-1">
+ <REFSECT2INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ <replaceable class="parameter">typename</replaceable>
+ </ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of a type to be created.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ <replaceable class="parameter">internallength</replaceable>
+ </ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A literal value, which specifies the internal length of
+ the new type.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ <replaceable class="parameter">externallength</replaceable>
+ </ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A literal value, which specifies the external length of
+ the new type.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ <replaceable class="parameter">input_function</replaceable>
+ </ReturnValue>
+ </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>
+ <ReturnValue>
+ <replaceable class="parameter">output_function</replaceable>
+ </ReturnValue>
+ </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>
+ <ReturnValue>
+ <replaceable class="parameter">element</replaceable>
+ </ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The type being created is an array; this specifies
+ the type of the array elements.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ <replaceable class="parameter">delimiter</replaceable>
+ </ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The delimiter character for the array.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ <replaceable class="parameter">default</replaceable
+ ></ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The default text to be displayed to indicate "data
+ not present"
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ <replaceable class="parameter">send_function</replaceable>
+ </ReturnValue>
+ </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>
+ <ReturnValue>
+ <replaceable class="parameter">receive_function</replaceable>
+ </ReturnValue>
+ </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>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-CREATETYPE-2">
+ <REFSECT2INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>CREATE</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if the type is successfully created.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-CREATETYPE-1">
+ <REFSECT1INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ CREATE TYPE 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
+ 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
+ (using create function) before defining the type. The
+ representation of a new base type is determined by
+ <replaceable class="parameter">input_function</replaceable>, which
+ converts the type's external representation to an internal
+ representation usable by the
+ operators and functions defined for the type. Naturally,
+ <replaceable class="parameter">output_function</replaceable>
+ performs the reverse transformation. Both
+ the input and output functions must be declared to take
+ one or two arguments of type "<literal>opaque</literal>".
+ </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,
+ in which case Postgres assumes that the new type has the
+ same format
+ 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.
+ The external representation is similarly specified using the
+ <replaceable class="parameter">externallength</replaceable>
+ keyword.
+ </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>
+ 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>
+ 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>
+ </para>
+ <PARA>
+ The optional functions
+ <replaceable class="parameter">send_function</replaceable> and
+ <replaceable class="parameter">receive_function</replaceable>
+ are used when the application program requesting Postgres
+ services resides on a different machine. In this case,
+ the machine on which Postgres runs may use a format for the data
+ type different from that used on the remote machine.
+ In this case it is appropriate to convert data items to a
+ standard form when sending from the server to the client
+ and converting from the standard format to the machine
+ specific format when the server receives the data from the
+ client. If these functions are not specified, then it is
+ assumed that the internal format of the type is acceptable
+ on all relevant machine architectures. For example, single
+ 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
+ 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>
+ 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>
+ </refsect2>
+
+ <refsect2>
+ <title>Large Object Types</title>
+ <para>
+ A "regular" Postgres type can only be 8192 bytes in
+ length. If you need a larger type you must create a Large
+ Object type. The interface for these types is discussed
+ at length in
+<comment>This section reference needs replacing</comment>
+ Section 7, the large object interface. The
+ length of all large object types is always VARIABLE.
+ </refsect2>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+ This command creates the box data type and then uses the
+ 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)
+ </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>
+ <para>
+ This command creates a large object type and uses it in
+ a class definition.
+ </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>
+ Type names cannot begin with the underscore character
+ ("_") and can only be 15 characters long. This is because
+ Postgres silently creates an array type for each base type
+ with a name consisting of the base type's name prepended
+ with an underscore.
+ </para>
+ </refsect2>
+ <REFSECT2 ID="R2-SQL-CREATETYPE-3">
+ <REFSECT2INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ Refer to DROP TYPE statement to drop types.
+ </PARA>
+ <PARA>
+ See also CREATE FUNCTION, CREATE OPERATOR and large_objects.</para>
+ </REFSECT2>
+ </refsect1>
+
+
+ <REFSECT1 ID="R1-SQL-CREATETYPE-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ CREATE TYPE statement is a PostgreSQL language extension.
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-CREATETYPE-4">
+ <REFSECT2INFO>
+ <DATE>1998-04-15</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL3
+ </TITLE>
+ <PARA>
+ CREATE TYPE is a SQL3 statement.
+ </PARA>
+
+ </REFSECT2>
+</REFENTRY>
+
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+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:
+-->
\ No newline at end of file