Commit 3450fd08 authored by Peter Eisentraut's avatar Peter Eisentraut

More editing of reference pages.

parent 8a703496
This diff is collapsed.
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_cast.sgml,v 1.10 2003/03/25 16:15:39 petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_cast.sgml,v 1.11 2003/04/22 10:08:08 petere Exp $ -->
<refentry id="SQL-CREATECAST">
<refmeta>
......@@ -58,11 +58,11 @@ SELECT CAST(42 AS text);
<para>
If the cast is marked <literal>AS ASSIGNMENT</> then it can be invoked
implicitly when assigning to a column of the target data type.
implicitly when assigning a value to a column of the target data type.
For example, supposing that <literal>foo.f1</literal> is a column of
type <type>text</type>, then
<programlisting>
INSERT INTO foo(f1) VALUES(42);
INSERT INTO foo (f1) VALUES (42);
</programlisting>
will be allowed if the cast from type <type>integer</type> to type
<type>text</type> is marked <literal>AS ASSIGNMENT</>, otherwise
......@@ -75,7 +75,7 @@ INSERT INTO foo(f1) VALUES(42);
If the cast is marked <literal>AS IMPLICIT</> then it can be invoked
implicitly in any context, whether assignment or internally in an
expression. For example, since <literal>||</> takes <type>text</>
arguments,
operands,
<programlisting>
SELECT 'The time is ' || now();
</programlisting>
......@@ -106,14 +106,16 @@ SELECT 'The time is ' || CAST(now() AS text);
<para>
To be able to create a cast, you must own the source or the target
data type. To create a binary-compatible cast, you must be superuser
(this restriction is made because an erroneous binary-compatible cast
conversion can easily crash the server).
data type. To create a binary-compatible cast, you must be superuser.
(This restriction is made because an erroneous binary-compatible cast
conversion can easily crash the server.)
</para>
</refsect1>
<variablelist>
<title>Parameters</title>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><replaceable>sourcetype</replaceable></term>
......@@ -183,6 +185,21 @@ SELECT 'The time is ' || CAST(now() AS text);
</refsect1>
<refsect1>
<title>Diagnostics</title>
<variablelist>
<varlistentry>
<term><computeroutput>CREATE CAST</computeroutput></term>
<listitem>
<para>
Message returned if the cast was successfully created.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="sql-createcast-notes">
<title>Notes</title>
......@@ -201,8 +218,8 @@ SELECT 'The time is ' || CAST(now() AS text);
argument of a different type was automatically a cast function.
This convention has been abandoned in face of the introduction of
schemas and to be able to represent binary compatible casts in the
catalogs. (The built-in cast functions still follow this naming
scheme, but they have to be shown as casts in <literal>pg_cast</>
system catalogs. (The built-in cast functions still follow this naming
scheme, but they have to be shown as casts in the system catalog <literal>pg_cast</>
now.)
</para>
</refsect1>
......@@ -227,7 +244,7 @@ CREATE CAST (text AS int4) WITH FUNCTION int4(text);
<para>
The <command>CREATE CAST</command> command conforms to SQL99,
except that SQL99 does not make provisions for binary compatible
except that SQL99 does not make provisions for binary-compatible
types. <literal>AS IMPLICIT</> is a <productname>PostgreSQL</productname>
extension, too.
</para>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_constraint.sgml,v 1.8 2002/05/18 15:44:47 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_constraint.sgml,v 1.9 2003/04/22 10:08:08 petere Exp $
PostgreSQL documentation
-->
......@@ -8,30 +8,35 @@ PostgreSQL documentation
<refentrytitle id="sql-createconstraint-title">CREATE CONSTRAINT TRIGGER</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
CREATE CONSTRAINT TRIGGER
</refname>
<refpurpose>
define a new constraint trigger
</refpurpose>
<refname>CREATE CONSTRAINT TRIGGER</refname>
<refpurpose>define a new constraint trigger</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>2000-04-13</date>
</refsynopsisdivinfo>
<synopsis>
<synopsis>
CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
AFTER <replaceable class="parameter">events</replaceable> ON
<replaceable class="parameter">relation</replaceable> <replaceable class="parameter">constraint</replaceable> <replaceable class="parameter">attributes</replaceable>
FOR EACH ROW EXECUTE PROCEDURE <replaceable class="parameter">func</replaceable> '(' <replaceable class="parameter">args</replaceable> ')'
</synopsis>
<replaceable class="parameter">table</replaceable> <replaceable class="parameter">constraint</replaceable> <replaceable class="parameter">attributes</replaceable>
FOR EACH ROW EXECUTE PROCEDURE <replaceable class="parameter">func</replaceable> ( <replaceable class="parameter">args</replaceable> )
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>CREATE CONSTRAINT TRIGGER</command> is used within
<command>CREATE TABLE</command>/<command>ALTER TABLE</command> and by
<application>pg_dump</application> to create the special triggers for
referential integrity.
It is not intended for general use.
</para>
</refsect1>
<refsect2 id="R2-SQL-CREATECONSTRAINT-1">
<title>
Inputs
</title>
<para>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
......@@ -53,10 +58,10 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
</varlistentry>
<varlistentry>
<term><replaceable class="PARAMETER">relation</replaceable></term>
<term><replaceable class="PARAMETER">table</replaceable></term>
<listitem>
<para>
The name (possibly schema-qualified) of the relation in which
The name (possibly schema-qualified) of the table in which
the triggering events occur.
</para>
</listitem>
......@@ -75,7 +80,7 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
<term><replaceable class="PARAMETER">attributes</replaceable></term>
<listitem>
<para>
Constraint attributes.
The constraint attributes.
</para>
</listitem>
</varlistentry>
......@@ -84,25 +89,19 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
<term><replaceable class="PARAMETER">func</replaceable>(<replaceable class="PARAMETER">args</replaceable>)</term>
<listitem>
<para>
Function to call as part of the trigger processing.
The function to call as part of the trigger processing.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsect1>
<refsect2 id="R2-SQL-CREATECONSTRAINT-2">
<title>
Outputs
</title>
<para>
<refsect1>
<title>Diagnostics</title>
<variablelist>
<varlistentry>
<term><computeroutput>
CREATE TRIGGER
</computeroutput></term>
<term><computeroutput>CREATE TRIGGER</computeroutput></term>
<listitem>
<para>
Message returned if successful.
......@@ -110,24 +109,6 @@ CREATE TRIGGER
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-SQL-CREATECONSTRAINT-1">
<title>
Description
</title>
<para>
<command>CREATE CONSTRAINT TRIGGER</command> is used within
<command>CREATE/ALTER TABLE</command> and by
<application>pg_dump</application> to create the special triggers for
referential integrity.
</para>
<para>
It is not intended for general use.
</para>
</refsect1>
</refentry>
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.7 2003/03/25 16:15:39 petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.8 2003/04/22 10:08:08 petere Exp $ -->
<refentry id="SQL-CREATECONVERSION">
<refmeta>
......@@ -23,21 +23,24 @@ CREATE [DEFAULT] CONVERSION <replaceable>conversion_name</replaceable>
<para>
<command>CREATE CONVERSION</command> defines a new encoding
conversion. Conversion names may be used in the CONVERT() function
conversion. Conversion names may be used in the <function>convert</function> function
to specify a particular encoding conversion. Also, conversions that
are marked DEFAULT can be used for automatic encoding conversion between
frontend and backend. For this purpose, two conversions, from encoding A to
B AND from encoding B to A, must be defined.
are marked <literal>DEFAULT</> can be used for automatic encoding conversion between
client and server. For this purpose, two conversions, from encoding A to
B <emphasis>and</emphasis> from encoding B to A, must be defined.
</para>
<para>
To be able to create a conversion, you must have the execute right
on the function and the create right on the destination schema.
To be able to create a conversion, you must have <literal>EXECUTE</literal> privilege
on the function and <literal>CREATE</literal> privilege on the destination schema.
</para>
</refsect1>
<variablelist>
<title>Parameters</title>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><literal>DEFAULT</literal></term>
......@@ -75,7 +78,7 @@ CREATE [DEFAULT] CONVERSION <replaceable>conversion_name</replaceable>
</varlistentry>
<varlistentry>
<term><replaceable>source_encoding</replaceable></term>
<term><replaceable>dest_encoding</replaceable></term>
<listitem>
<para>
......@@ -92,25 +95,39 @@ CREATE [DEFAULT] CONVERSION <replaceable>conversion_name</replaceable>
The function used to perform the conversion. The function name may
be schema-qualified. If it is not, the function will be looked
up in the path.
</para>
</para>
<para>
<para>
The function must have the following signature:
<programlisting>
conv_proc(
INTEGER, -- source encoding id
INTEGER, -- destination encoding id
CSTRING, -- source string (null terminated C string)
CSTRING, -- destination string (null terminated C string)
INTEGER -- source string length
) returns VOID;
</programlisting>
<programlisting>
conv_proc(
integer, -- source encoding ID
integer, -- destination encoding ID
cstring, -- source string (null terminated C string)
cstring, -- destination string (null terminated C string)
integer -- source string length
) RETURNS void;
</programlisting>
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Diagnostics</title>
<variablelist>
<varlistentry>
<term><computeroutput>CREATE CONVERSION</computeroutput></term>
<listitem>
<para>
Message returned if the conversion was successfully created.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="sql-createconversion-notes">
......@@ -124,15 +141,14 @@ CREATE [DEFAULT] CONVERSION <replaceable>conversion_name</replaceable>
The privileges required to create a conversion may be changed in a future
release.
</para>
</refsect1>
<refsect1 id="sql-createconversion-examples">
<title>Examples</title>
<para>
To create a conversion from encoding UNICODE to LATIN1 using <function>myfunc</>:
To create a conversion from encoding <literal>UNICODE</literal> to
<literal>LATIN1</literal> using <function>myfunc</>:
<programlisting>
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
</programlisting>
......@@ -147,7 +163,7 @@ CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
<command>CREATE CONVERSION</command>
is a <productname>PostgreSQL</productname> extension.
There is no <command>CREATE CONVERSION</command>
statement in <acronym>SQL99</acronym>.
statement in the SQL standard.
</para>
</refsect1>
......
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.12 2003/03/25 16:15:39 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.13 2003/04/22 10:08:08 petere Exp $
PostgreSQL documentation
-->
<refentry id="SQL-CREATEDOMAIN">
<refmeta>
<refentrytitle id="sql-createdomain-title">
CREATE DOMAIN
</refentrytitle>
<refentrytitle id="sql-createdomain-title">CREATE DOMAIN</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
CREATE DOMAIN
</refname>
<refpurpose>
define a new domain
</refpurpose>
<refname>CREATE DOMAIN</refname>
<refpurpose>define a new domain</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>2002-02-24</date>
</refsynopsisdivinfo>
<synopsis>
<synopsis>
CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> [AS] <replaceable class="parameter">data_type</replaceable>
[ DEFAULT <replaceable>default_expr</> ]
[ <replaceable class="PARAMETER">constraint</replaceable> [ ... ] ]
......@@ -31,16 +24,35 @@ where <replaceable class="PARAMETER">constraint</replaceable> is:
[ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
{ NOT NULL | NULL | CHECK (<replaceable class="PARAMETER">expression</replaceable>) }
</synopsis>
</synopsis>
</refsynopsisdiv>
<refsect2 id="R2-SQL-CREATEDOMAIN-1">
<refsect2info>
<date>2002-02-24</date>
</refsect2info>
<title>
Parameters
</title>
<para>
<refsect1>
<title>Description</title>
<para>
<command>CREATE DOMAIN</command> creates a new data domain. The
user who defines a domain becomes its owner.
</para>
<para>
If a schema name is given (for example, <literal>CREATE DOMAIN
myschema.mydomain ...</>) then the domain is created in the
specified schema. Otherwise it is created in the current schema.
The domain name must be unique among the types and domains existing
in its schema.
</para>
<para>
Domains are useful for abstracting common fields between tables into
a single location for maintenance. For example, an email address column may be used
in several tables, all with the same properties. Define a domain and
use that rather than setting up each table's constraints individually.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
......@@ -63,32 +75,26 @@ where <replaceable class="PARAMETER">constraint</replaceable> is:
</varlistentry>
<varlistentry>
<term><literal>DEFAULT
<replaceable>default_expr</replaceable></literal></term>
<term><literal>DEFAULT <replaceable>default_expr</replaceable></literal></term>
<listitem>
<para>
The <literal>DEFAULT</> clause specifies a default value for
columns of the domain data type. The value
is any variable-free expression (but subselects are not allowed).
The
data type of the default expression must match the data type of the
domain.
columns of the domain data type. The value is any
variable-free expression (but subqueries are not allowed).
The data type of the default expression must match the data
type of the domain. If no default value is specified, then
the default value is the null value.
</para>
<para>
The default expression will be used in any insert operation that
does not specify a value for the column. If there is no default
for a domain, then the default is NULL.
The default expression will be used in any insert operation
that does not specify a value for the column. If a default
value is defined for a particular column, it overrides any
default associated with the domain. In turn, the domain
default overrides any default value associated with the
underlying data type.
</para>
<note>
<para>
If a default value is specified for a particular column, it
overrides any default associated with the domain. In turn,
the domain default overrides any default value associated with
the underlying data type.
</para>
</note>
</listitem>
</varlistentry>
......@@ -106,7 +112,7 @@ where <replaceable class="PARAMETER">constraint</replaceable> is:
<term><literal>NOT NULL</></term>
<listitem>
<para>
Values of this domain are not allowed to be NULL.
Values of this domain are not allowed to be null.
</para>
</listitem>
</varlistentry>
......@@ -115,12 +121,12 @@ where <replaceable class="PARAMETER">constraint</replaceable> is:
<term><literal>NULL</></term>
<listitem>
<para>
Values of this domain are allowed to be NULL. This is the default.
Values of this domain are allowed to be null. This is the default.
</para>
<para>
This clause is only available for compatibility with
non-standard SQL databases. Its use is discouraged in new
This clause is only intended for compatibility with
nonstandard SQL databases. Its use is discouraged in new
applications.
</para>
</listitem>
......@@ -139,84 +145,50 @@ where <replaceable class="PARAMETER">constraint</replaceable> is:
<para>
Currently, <literal>CHECK</literal> expressions cannot contain
subselects nor refer to variables other than <literal>VALUE</>.
subqueries nor refer to variables other than <literal>VALUE</>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</variablelist>
</para>
</refsect2>
<refsect2 id="R2-SQL-CREATEDOMAIN-2">
<refsect2info>
<date>2002-02-24</date>
</refsect2info>
<title>
Outputs
</title>
<para>
<variablelist>
<varlistentry>
<term><computeroutput>
CREATE DOMAIN
</computeroutput></term>
<listitem>
<para>
Message returned if the domain is successfully created.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-SQL-CREATEDOMAIN-1">
<refsect1info>
<date>2002-02-24</date>
</refsect1info>
<title>
Description
</title>
<para>
<command>CREATE DOMAIN</command> allows the user to register a new
data domain with <productname>PostgreSQL</> for use in the
current data base. The user who defines a domain becomes its owner.
</para>
<para>
If a schema name is given (for example, <literal>CREATE DOMAIN
myschema.mydomain ...</>) then the domain is created in the
specified schema. Otherwise it is created in the current schema (the one
at the front of the search path; see <literal>CURRENT_SCHEMA()</>).
The domain name must be unique among the types and domains existing
in its schema.
</para>
<refsect1>
<title>Diagnostics</title>
<para>
Domains are useful for abstracting common fields between tables into
a single location for maintenance. An email address column may be used
in several tables, all with the same properties. Define a domain and
use that rather than setting up each table's constraints individually.
</para>
<variablelist>
<varlistentry>
<term><computeroutput>CREATE DOMAIN</computeroutput></term>
<listitem>
<para>
Message returned if the domain was successfully created.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
This example creates the <type>country_code</type> data type and then uses the
type in a table definition:
<programlisting>
CREATE DOMAIN country_code char(2) NOT NULL;
CREATE TABLE countrylist (id INT4, country country_code);
CREATE TABLE countrylist (id integer, country country_code);
</programlisting>
</para>
</refsect1>
<refsect1 id="SQL-CREATEDOMAIN-compatibility">
<title>Compatibility</title>
<para>
The command <command>CREATE DOMAIN</command> conforms to the SQL
standard.
</para>
</refsect1>
<refsect1 id="SQL-CREATEDOMAIN-see-also">
<title>See Also</title>
......
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_group.sgml,v 1.10 2003/03/25 16:15:39 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_group.sgml,v 1.11 2003/04/22 10:08:08 petere Exp $
PostgreSQL documentation
-->
......@@ -8,35 +8,41 @@ PostgreSQL documentation
<refentrytitle id="sql-creategroup-title">CREATE GROUP</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
CREATE GROUP
</refname>
<refpurpose>
define a new user group
</refpurpose>
<refname>CREATE GROUP</refname>
<refpurpose>define a new user group</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>2000-01-14</date>
</refsynopsisdivinfo>
<synopsis>
<synopsis>
CREATE GROUP <replaceable class="PARAMETER">name</replaceable> [ [ WITH ] <replaceable class="PARAMETER">option</replaceable> [ ... ] ]
where <replaceable class="PARAMETER">option</replaceable> can be:
SYSID <replaceable class="PARAMETER">gid</replaceable>
| USER <replaceable class="PARAMETER">username</replaceable> [, ...]
</synopsis>
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>CREATE GROUP</command> will create a new group in the
database cluster. You must be a database
superuser to use this command.
</para>
<para>
Use <xref linkend="SQL-ALTERGROUP" endterm="SQL-ALTERGROUP-title">
to change a group's membership, and <xref linkend="SQL-DROPGROUP"
endterm="SQL-DROPGROUP-title"> to remove a group.
</para>
</refsect1>
<refsect2 id="R2-SQL-CREATEGROUP-1">
<refsect2info>
<date>2000-01-14</date>
</refsect2info>
<title>
Inputs
</title>
<para>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
......@@ -53,11 +59,11 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
<listitem>
<para>
The <literal>SYSID</literal> clause can be used to choose
the <productname>PostgreSQL</productname> group id of the new
the <productname>PostgreSQL</productname> group ID of the new
group. It is not necessary to do so, however.
</para>
<para>
If this is not specified, the highest assigned group id plus one,
If this is not specified, the highest assigned group ID plus one,
starting at 1, will be used as default.
</para>
</listitem>
......@@ -73,54 +79,26 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsect1>
<refsect2 id="R2-SQL-CREATEGROUP-2">
<refsect2info>
<date>2000-01-14</date>
</refsect2info>
<title>
Outputs
</title>
<para>
<refsect1>
<title>Diagnostics</title>
<variablelist>
<varlistentry>
<term><computeroutput>CREATE GROUP</computeroutput></term>
<listitem>
<para>
Message returned if the command completes successfully.
Message returned if the group was successfully created.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
</refsect1>
<refsect1>
<title>Examples</title>
<refsect1 id="R1-SQL-CREATEGROUP-1">
<refsect1info>
<date>2000-01-14</date>
</refsect1info>
<title>
Description
</title>
<para>
<command>CREATE GROUP</command> will create a new group in the
database installation. You must be a database
superuser to use this command.
</para>
<para>
Use <xref linkend="SQL-ALTERGROUP" endterm="SQL-ALTERGROUP-title">
to change a group's membership, and <xref linkend="SQL-DROPGROUP"
endterm="SQL-DROPGROUP-title"> to remove a group.
</para>
</refsect1>
<refsect1 id="R1-SQL-CREATEGROUP-2">
<title>
Usage
</title>
<para>
Create an empty group:
<programlisting>
......@@ -136,24 +114,13 @@ CREATE GROUP marketing WITH USER jonathan, david;
</para>
</refsect1>
<refsect1 id="R1-SQL-CREATEGROUP-3">
<title>
Compatibility
</title>
<refsect1>
<title>Compatibility</title>
<refsect2 id="R2-SQL-CREATEGROUP-4">
<refsect2info>
<date>2000-01-14</date>
</refsect2info>
<title>
SQL92
</title>
<para>
There is no <command>CREATE GROUP</command> statement in SQL92.
Roles are similar in concept to groups.
</para>
</refsect2>
<para>
There is no <command>CREATE GROUP</command> statement in the SQL
standard. Roles are similar in concept to groups.
</para>
</refsect1>
</refentry>
......
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.31 2003/03/25 16:15:39 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.32 2003/04/22 10:08:08 petere Exp $
PostgreSQL documentation
-->
......@@ -60,7 +60,7 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langna
<literal>TRUSTED</literal> specifies that the call handler for
the language is safe, that is, it does not offer an
unprivileged user any functionality to bypass access
restrictions. If this keyword is omitted when registering the
restrictions. If this key word is omitted when registering the
language, only users with the
<productname>PostgreSQL</productname> superuser privilege can
use this language to create new functions.
......@@ -84,8 +84,8 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langna
<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>PostgreSQL</productname>.
case insensitive. The name must be unique among the languages
in the database.
</para>
<para>
......@@ -146,45 +146,16 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langna
<refsect1 id="sql-createlanguage-diagnostics">
<title>Diagnostics</title>
<msgset>
<msgentry>
<msg>
<msgmain>
<msgtext>
<screen>
CREATE LANGUAGE
</screen>
</msgtext>
</msgmain>
</msg>
<msgexplan>
<variablelist>
<varlistentry>
<term><computeroutput>CREATE LANGUAGE</computeroutput></term>
<listitem>
<para>
This message is returned if the language is successfully
created.
Message returned if the language was successfully created.
</para>
</msgexplan>
</msgentry>
<msgentry>
<msg>
<msgmain>
<msgtext>
<screen>
ERROR: PL handler function <replaceable class="parameter">funcname</replaceable>() doesn't exist
</screen>
</msgtext>
</msgmain>
</msg>
<msgexplan>
<para>
This error is returned if the function <replaceable
class="parameter">funcname</replaceable>() is not found.
</para>
</msgexplan>
</msgentry>
</msgset>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="sql-createlanguage-notes">
......@@ -194,7 +165,7 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
This command normally should not be executed directly by users.
For the procedural languages supplied in the
<productname>PostgreSQL</productname> distribution, the <xref
linkend="app-createlang"> script should be used, which will also
linkend="app-createlang"> program should be used, which will also
install the correct call handler. (<command>createlang</command>
will call <command>CREATE LANGUAGE</command> internally.)
</para>
......@@ -205,7 +176,7 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
type <type>opaque</>, rather than <type>language_handler</>.
To support loading
of old dump files, <command>CREATE LANGUAGE</> will accept a function
declared as returning <type>opaque</>, but it will issue a NOTICE and
declared as returning <type>opaque</>, but it will issue a notice and
change the function's declared return type to <type>language_handler</>.
</para>
......@@ -216,35 +187,19 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
<para>
Use <xref linkend="sql-droplanguage" endterm="sql-droplanguage-title">, or better yet the <xref
linkend="app-droplang"> script, to drop procedural languages.
linkend="app-droplang"> program, to drop procedural languages.
</para>
<para>
The system catalog <classname>pg_language</classname> records
information about the currently installed procedural languages.
<screen>
Table "pg_language"
Attribute | Type | Modifier
---------------+-----------+----------
lanname | name |
lanispl | boolean |
lanpltrusted | boolean |
lanplcallfoid | oid |
lanvalidator | oid |
lanacl | aclitem[] |
lanname | lanispl | lanpltrusted | lanplcallfoid | lanvalidator | lanacl
-------------+---------+--------------+---------------+--------------+--------
internal | f | f | 0 | 2246 |
c | f | f | 0 | 2247 |
sql | f | t | 0 | 2248 | {=U}
</screen>
The system catalog <classname>pg_language</classname> (see <xref
linkend="catalog-pg-language">) records information about the
currently installed languages. Also <command>createlang</command>
has an option to list the installed languages.
</para>
<para>
At present, with the exception of the permissions, the definition
of a procedural language cannot be changed once it has been created.
The definition of a procedural language cannot be changed once it
has been created, with the exception of the privileges.
</para>
<para>
......@@ -262,7 +217,7 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
The following two commands executed in sequence will register a new
procedural language and the associated call handler.
<programlisting>
CREATE FUNCTION plsample_call_handler () RETURNS language_handler
CREATE FUNCTION plsample_call_handler() RETURNS language_handler
AS '$libdir/plsample'
LANGUAGE C;
CREATE LANGUAGE plsample
......@@ -280,15 +235,6 @@ CREATE LANGUAGE plsample
</para>
</refsect1>
<refsect1>
<title>History</title>
<para>
The <command>CREATE LANGUAGE</command> command first appeared in
<productname>PostgreSQL</productname> 6.3.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.4 2003/02/03 15:56:50 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.5 2003/04/22 10:08:08 petere Exp $
PostgreSQL documentation
-->
......@@ -8,25 +8,51 @@ PostgreSQL documentation
<refentrytitle id="sql-createschema-title">CREATE SCHEMA</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
CREATE SCHEMA
</refname>
<refpurpose>
define a new schema
</refpurpose>
<refname>CREATE SCHEMA</refname>
<refpurpose>define a new schema</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
<synopsis>
CREATE SCHEMA <replaceable class="parameter">schemaname</replaceable> [ AUTHORIZATION <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable> [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
</synopsis>
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>CREATE SCHEMA</command> will enter a new schema
into the current database.
The schema name must be distinct from the name of any existing schema
in the current database.
</para>
<para>
A schema is essentially a namespace:
it contains named objects (tables, data types, functions, and operators)
whose names may duplicate those of other objects existing in other
schemas. Named objects are accessed either by <quote>qualifying</>
their names with the schema name as a prefix, or by setting a search
path that includes the desired schema(s). Unqualified objects are
created in the current schema (the one at the front of the search path,
which can be determined with the function <function>current_schema</function>).
</para>
<para>
Optionally, <command>CREATE SCHEMA</command> can include subcommands
to create objects within the new schema. The subcommands are treated
essentially the same as separate commands issued after creating the
schema, except that if the <literal>AUTHORIZATION</> clause is used,
all the created objects will be owned by that user.
</para>
</refsect1>
<refsect2 id="R2-SQL-CREATESCHEMA-1">
<title>
Inputs
</title>
<para>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
......@@ -63,164 +89,112 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
<refsect2 id="R2-SQL-CREATESCHEMA-2">
<title>
Outputs
</title>
<para>
</refsect1>
<variablelist>
<varlistentry>
<term><computeroutput>
CREATE SCHEMA
</computeroutput></term>
<listitem>
<para>
Message returned if the command is successful.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><computeroutput>
ERROR: namespace "<replaceable class="parameter">schemaname</replaceable>" already exists
</computeroutput></term>
<listitem>
<para>
If the schema specified already exists.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<refsect1>
<title>Diagnostics</title>
<variablelist>
<varlistentry>
<term><computeroutput>CREATE SCHEMA</computeroutput></term>
<listitem>
<para>
Message returned if the schema was successfully created.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><computeroutput>ERROR: namespace "<replaceable class="parameter">schemaname</replaceable>" already exists</computeroutput></term>
<listitem>
<para>
Message returned if the schema specified already exists.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="R1-SQL-CREATESCHEMA-1">
<title>
Description
</title>
<para>
<command>CREATE SCHEMA</command> will enter a new schema
into the current database.
The schema name must be distinct from the name of any existing schema
in the current database.
</para>
<refsect1>
<title>Notes</title>
<para>
A schema is essentially a namespace:
it contains named objects (tables, data types, functions, and operators)
whose names may duplicate those of other objects existing in other
schemas. Named objects are accessed either by <quote>qualifying</>
their names with the schema name as a prefix, or by setting a search
path that includes the desired schema(s). Unqualified objects are
created in the current schema (the one at the front of the search path;
see <literal>CURRENT_SCHEMA()</>).
To create a schema, the invoking user must have <literal>CREATE</>
privilege for the current database. (Of course, superusers bypass
this check.)
</para>
<para>
Optionally, <command>CREATE SCHEMA</command> can include subcommands
to create objects within the new schema. The subcommands are treated
essentially the same as separate commands issued after creating the
schema, except that if the <literal>AUTHORIZATION</> clause is used,
all the created objects will be owned by that user.
Use <command>DROP SCHEMA</command> to remove a schema.
</para>
<refsect2 id="R2-SQL-CREATESCHEMA-3">
<title>
Notes
</title>
<para>
To create a schema, the invoking user must have <literal>CREATE</>
privilege for the current database. (Of course, superusers bypass
this check.)
</para>
<para>
Use <command>DROP SCHEMA</command> to remove a schema.
</para>
</refsect2>
</refsect1>
<refsect1 id="R1-SQL-CREATESCHEMA-2">
<title>
Examples
</title>
<refsect1>
<title>Examples</title>
<para>
Create a schema:
<programlisting>
<programlisting>
CREATE SCHEMA myschema;
</programlisting>
</programlisting>
</para>
<para>
Create a schema for user <literal>joe</> --- the schema will also
be named <literal>joe</>:
<programlisting>
Create a schema for user <literal>joe</>; the schema will also be
named <literal>joe</>:
<programlisting>
CREATE SCHEMA AUTHORIZATION joe;
</programlisting>
</programlisting>
</para>
<para>
Create a schema and create a table and view within it:
<programlisting>
<programlisting>
CREATE SCHEMA hollywood
CREATE TABLE films (title text, release date, awards text[])
CREATE VIEW winners AS
SELECT title, release FROM films WHERE awards IS NOT NULL;
</programlisting>
</programlisting>
Notice that the individual subcommands do not end with semicolons.
</para>
<para>
The following is an equivalent way of accomplishing the same result:
<programlisting>
<programlisting>
CREATE SCHEMA hollywood;
CREATE TABLE hollywood.films (title text, release date, awards text[]);
CREATE VIEW hollywood.winners AS
SELECT title, release FROM hollywood.films WHERE awards IS NOT NULL;
</programlisting>
</programlisting>
</para>
</refsect1>
<refsect1 id="R1-SQL-CREATESCHEMA-3">
<title>
Compatibility
</title>
<refsect2 id="R2-SQL-CREATESCHEMA-4">
<title>
SQL92
</title>
<para>
SQL92 allows a <literal>DEFAULT CHARACTER SET</> clause in
<command>CREATE SCHEMA</command>, as well as more subcommand types
than are presently accepted by <productname>PostgreSQL</productname>.
</para>
<para>
SQL92 specifies that the subcommands in <command>CREATE SCHEMA</command>
may appear in any order. The present
<productname>PostgreSQL</productname> implementation does not handle all
cases of forward references in subcommands; it may sometimes be necessary
to reorder the subcommands to avoid forward references.
</para>
<para>
In SQL92, the owner of a schema always owns all objects within it.
<productname>PostgreSQL</productname> allows schemas to contain objects
owned by users other than the schema owner. This can happen only if the
schema owner grants <literal>CREATE</> rights on his schema to someone
else.
</para>
</refsect2>
<refsect1>
<title>Compatibility</title>
<para>
The SQL standard allows a <literal>DEFAULT CHARACTER SET</> clause
in <command>CREATE SCHEMA</command>, as well as more subcommand
types than are presently accepted by
<productname>PostgreSQL</productname>.
</para>
<para>
The SQL standard specifies that the subcommands in <command>CREATE
SCHEMA</command> may appear in any order. The present
<productname>PostgreSQL</productname> implementation does not
handle all cases of forward references in subcommands; it may
sometimes be necessary to reorder the subcommands to avoid forward
references.
</para>
<para>
According to the SQL standard, the owner of a schema always owns
all objects within it. <productname>PostgreSQL</productname>
allows schemas to contain objects owned by users other than the
schema owner. This can happen only if the schema owner grants the
<literal>CREATE</> privilege on his schema to someone else.
</para>
</refsect1>
</refentry>
......
This diff is collapsed.
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.11 2002/11/21 23:34:43 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.12 2003/04/22 10:08:08 petere Exp $
PostgreSQL documentation
-->
......@@ -18,16 +18,12 @@ PostgreSQL documentation
<synopsis>
CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ]
AS <replaceable>query</replaceable>
</synopsis>
</synopsis>
</refsynopsisdiv>
<refsect1>
<refsect1info>
<date>2001-03-20</date>
</refsect1info>
<title>
Description
</title>
<title>Description</title>
<para>
<command>CREATE TABLE AS</command> creates a table and fills it
with data computed by a <command>SELECT</command> command. The
......@@ -75,10 +71,9 @@ CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replace
<term><replaceable>column_name</replaceable></term>
<listitem>
<para>
The name of a column in the new table. Multiple column names can
be specified using a comma-delimited list of column names. If
column names are not provided, they are taken from the output
column names of the query.
The name of a column in the new table. If column names are not
provided, they are taken from the output column names of the
query.
</para>
</listitem>
</varlistentry>
......@@ -124,21 +119,12 @@ CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replace
<para>
This command is modeled after an <productname>Oracle</productname>
feature. There is no command with equivalent functionality in
SQL92 or SQL99. However, a combination of <literal>CREATE
the SQL standard. However, a combination of <literal>CREATE
TABLE</literal> and <literal>INSERT ... SELECT</literal> can
accomplish the same thing with little more effort.
</para>
</refsect1>
<refsect1>
<title>History</title>
<para>
The <command>CREATE TABLE AS</command> command has been available
since <productname>PostgreSQL</productname> 6.3.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
......
This diff is collapsed.
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_user.sgml,v 1.25 2003/03/25 16:15:39 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_user.sgml,v 1.26 2003/04/22 10:08:08 petere Exp $
PostgreSQL documentation
-->
......@@ -33,16 +33,17 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
<title>Description</title>
<para>
<command>CREATE USER</command> will add a new user to an instance
of <productname>PostgreSQL</productname>. Refer to <xref linkend="user-manag">
for information about managing users and authentication. You must
be a database superuser to use this command.
<command>CREATE USER</command> adds a new user to a
<productname>PostgreSQL</productname> database cluster. Refer to
<xref linkend="user-manag"> and <xref
linkend="client-authentication"> for information about managing
users and authentication. You must be a database superuser to use
this command.
</para>
</refsect1>
<refsect2>
<title>Parameters</title>
<para>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
......@@ -60,9 +61,9 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
<para>
The <literal>SYSID</literal> clause can be used to choose the
<productname>PostgreSQL</productname> user ID of the user that
is being created. It is not at all necessary that those match
the Unix user IDs, but some people choose to keep the numbers
the same.
is being created. This is not normally not necessary, but may
be useful if you need to recreate the owner of an orphaned
object.
</para>
<para>
If this is not specified, the highest assigned user ID plus one
......@@ -76,10 +77,11 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
<listitem>
<para>
Sets the user's password. If you do not plan to use password
authentication you can omit this option, but the user
won't be able to connect to a password-authenticated server.
The password can be set or changed later, using
<xref linkend="SQL-ALTERUSER" endterm="SQL-ALTERUSER-title">.
authentication you can omit this option, but then the user
won't be able to connect if you decide to switch to password
authentication. The password can be set or changed later,
using <xref linkend="SQL-ALTERUSER"
endterm="SQL-ALTERUSER-title">.
</para>
</listitem>
</varlistentry>
......@@ -89,23 +91,22 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
<term><literal>UNENCRYPTED</></term>
<listitem>
<para>
These keywords control whether the password is stored
encrypted in <literal>pg_shadow</>. (If neither is specified,
the default behavior is determined by the
<varname>PASSWORD_ENCRYPTION</varname> server parameter.) If
the presented string is already in MD5-encrypted format, then
it is stored as-is, regardless of whether
<literal>ENCRYPTED</> or <literal>UNENCRYPTED</> is specified.
This allows reloading of encrypted passwords during
dump/restore.
These key words control whether the password is stored
encrypted in the system catalogs. (If neither is specified,
the default behavior is determined by the configuration
parameter <varname>password_encryption</varname>.) If the
presented password string is already in MD5-encrypted format,
then it is stored encrypted as-is, regardless of whether
<literal>ENCRYPTED</> or <literal>UNENCRYPTED</> is specified
(since the system cannot decrypt the specified encrypted
password string). This allows reloading of encrypted
passwords during dump/restore.
</para>
<para>
See <xref linkend="client-authentication">
for details on how to set up authentication mechanisms. Note
that older clients may lack support for the MD5 authentication
mechanism that is needed to work with passwords that are
stored encrypted.
Note that older clients may lack support for the MD5
authentication mechanism that is needed to work with passwords
that are stored encrypted.
</para>
</listitem>
</varlistentry>
......@@ -160,26 +161,21 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsect1>
<refsect1>
<title>Diagnostics</title>
<para>
<variablelist>
<varlistentry>
<term><computeroutput>CREATE USER</computeroutput></term>
<listitem>
<para>
Message returned if the command completes successfully.
Message returned if the user account was successfully created.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1>
......@@ -191,9 +187,12 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
endterm="SQL-DROPUSER-title"> to remove a user. Use <xref
linkend="SQL-ALTERGROUP" endterm="SQL-ALTERGROUP-title"> to add the
user to groups or remove the user from groups.
</para>
<para>
<productname>PostgreSQL</productname> includes a program <xref
linkend="APP-CREATEUSER" endterm="APP-CREATEUSER-title"> that has
the same functionality as this command (in fact, it calls this
the same functionality as <command>CREATE USER</command> (in fact, it calls this
command) but can be run from the command shell.
</para>
</refsect1>
......@@ -216,12 +215,12 @@ CREATE USER davide WITH PASSWORD 'jw8s0F4';
</para>
<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:
Create a user with a password that is valid until the end of 2004.
After one second has ticked in 2005, the password is no longer
valid.
<programlisting>
CREATE USER miriam WITH PASSWORD 'jw8s0F4' VALID UNTIL 'Jan 1 2002';
CREATE USER miriam WITH PASSWORD 'jw8s0F4' VALID UNTIL '2005-01-01';
</programlisting>
</para>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment