- The name of an existing table to alter.
+ The name of an existing table to alter.
- Name of a new or existing column.
+ Name of a new or existing column.
- Type of the new column.
+ Type of the new column.
- New name for an existing column.
+ New name for an existing column.
- New name for an existing column.
+ New name for an existing column.
+ Message returned from column or table renaming.
+ Message returned from column addition.
+ Message returned if table or column is not available.
executed.
You must own the table in order to change its schema.
-The keyword COLUMN is noise and can be omitted.
- inheritance hierarchy.
+ inheritance hierarchy.
+ information on inheritance.
+ of valid arguments.
-
-
-
- ALTER USER
-
- SQL - Language Statements
-
-
-
- ALTER USER
-
-
- Modifies user account information
-
+
+
+
+ ALTER USER
+
+ SQL - Language Statements
+
+
+
+ ALTER USER
+
+
+ Modifies user account information
+
-
-
- 1998-09-08
-
-
-ALTER USER username
- [ WITH PASSWORD password ]
- [ CREATEDB | NOCREATEDB ]
- [ CREATEUSER | NOCREATEUSER ]
+
+
+ 1998-09-08
+
+
+ALTER USER username [ WITH PASSWORD password ]
+ [ CREATEDB | NOCREATEDB ] [ CREATEUSER | NOCREATEUSER ]
[ IN GROUP groupname [, ...] ]
[ VALID UNTIL 'abstime ' ]
-
-
-
-
- 1998-09-08
-
-
- Inputs
-
- Refer to CREATE USER for a detailed description of each
- clause.
-
-
-
-
- username
-
-
- The Postgres account name of the user whose details are to be altered.
-
-
-
-
-
-
- password
-
-
- The new password to be used for this account.
-
-
-
-
-
-
- groupname
-
-
- The name of an access group into which this account is to be put.
-
-
-
-
-
-
- abstime
-
-
- The date (and, optionally, the time)
- at which this user's access is to be terminated.
-
-
-
-
-
+
+
+
+
+ 1998-09-08
+
+
+ Inputs
+
+
+ Refer to CREATE USER for a detailed description of each
+ clause.
+
+
+
+
+ username
+
+ The Postgres account name of the user whose details are to be altered.
+
+
+
+
+
+ password
+
+ The new password to be used for this account.
+
+
+
+
+
+ groupname
+
+ The name of an access group into which this account is to be put.
+
+
+
+
+
+ abstime
+
+ The date (and, optionally, the time)
+ at which this user's access is to be terminated.
+
+
+
+
+
+
-
-
- 1998-09-08
-
-
- Outputs
-
+
+
+ 1998-09-08
+
+
+ Outputs
+
-
- ALTER USER
-
+
+ALTER USER
+
Message returned if the alteration was successful.
-
- ERROR: alterUser: user "username" does not exist
-
+
+ERROR: alterUser: user "username" does not exist
+
- Error message returned if the user specified doesn't
- exist .
+ Error message returned if the specified user is not known to
+ the database .
-
-
-
- 1998-09-08
-
-
- Description
-
- ALTER USER is used to change the attributes of a user's
- 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
- user or any user with read and modify permissions on
- "pg_shadow" to alter user passwords.
-
- If any of the clauses of the alter user statement are
- omitted, the corresponding value in the "pg_shadow" table
- is left unchanged.
-
+
+
+
+ 1998-09-08
+
+
+ Description
+
+ ALTER USER is used to change the attributes of a user's
+ 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
+ user or any user with read and modify permissions on
+ pg_shadow to alter user passwords.
+
+
+ If any of the clauses of the alter user statement are
+ omitted, the corresponding value in the "pg_shadow" table
+ is left unchanged.
+
-
-
- 1998-09-08
-
-
- Notes
-
- ALTER USER statement
- language extension.
-
- Refer to CREATE/DROP USER
- to create or remove a user
- account.
-
- 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.
-
-
-
-
-
-
- Usage
-
- Change a user password
-
+
+
+ 1998-09-08
+
+
+ Notes
+
+ ALTER USER
+ language extension.
+
+ Refer to CREATE/DROP USER
+ to create or remove a user account.
+
+ 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.
+
+
+
+
+
+
+ Usage
+
+ Change a user password:
+
ALTER USER davide WITH PASSWORD hu8jmn3;
-
- Change a user's valid until date
-
+
+
+ Change a user's valid until date
+
ALTER USER manuel VALID UNTIL 'Jan 31 2030';
-
- 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
-
+
+
+ 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
ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
-
- Give a user the ability to create other users and new databases.
-
+
+
+ Give a user the ability to create other users and new databases.
+
ALTER USER miriam CREATEUSER CREATEDB;
-
- Place a user in two groups
-
+
+
+ Place a user in two groups
+
ALTER USER miriam IN GROUP sales, payroll;
-
-
-
-
-
- Compatibility
-
-
+
+
+
+
+
+
+ Compatibility
+
+
-
-
- 1998-09-08
-
-
- SQL92
-
- There is no ALTER USER statement in
- The standard leaves
- the definition of users to the implementation.
-
-
-
-
+
+
+ 1998-09-08
+
+
+ SQL92
+
+ There is no ALTER USER statement in
+ The standard leaves
+ the definition of users to the implementation.
+
+
+
+
next-internal-state1
- sfunc2 ( internal-state2 ) ---> next-internal-state2
+sfunc1 ( internal-state1, next-data_item ) ---> next-internal-state1 sfunc2 ( internal-state2 ) ---> next-internal-state2
and a final calculation function,
- <REPLACEABLE CLASS="PARAMETER">ffunc>:
+ <replaceable class="PARAMETER">ffunc>:
- ffunc >(internal-state1, internal-state2) ---> aggregate-value
+ffunc >(internal-state1, internal-state2) ---> aggregate-value
Postgres creates up to two temporary variables
- (referred to here as <REPLACEABLE CLASS="PARAMETER">temp1>
- and <REPLACEABLE CLASS="PARAMETER">temp2>)
+ (referred to here as <replaceable class="PARAMETER">temp1>
+ and <replaceable class="PARAMETER">temp2>)
to hold intermediate results used as arguments to the transition functions.
The arguments to
- <REPLACEABLE CLASS="PARAMETER">sfunc1>
+ <replaceable class="PARAMETER">sfunc1>
must be
- <REPLACEABLE CLASS="PARAMETER">temp1>
+ <replaceable class="PARAMETER">temp1>
of type
- <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type>
+ <replaceable class="PARAMETER">sfunc1_return_type>
and
- <REPLACEABLE CLASS="PARAMETER">column_value>
- of type <REPLACEABLE CLASS="PARAMETER">data_type>.
+ <replaceable class="PARAMETER">column_value>
+ of type <replaceable class="PARAMETER">data_type>.
The return value must be of type
- <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type>
+ <replaceable class="PARAMETER">sfunc1_return_type>
and will be used as the first argument in the next call to
- <REPLACEABLE CLASS="PARAMETER">sfunc1>.
+ <replaceable class="PARAMETER">sfunc1>.
The argument and return value of
- <REPLACEABLE CLASS="PARAMETER">sfunc2>
+ <replaceable class="PARAMETER">sfunc2>
must be
- <REPLACEABLE CLASS="PARAMETER">temp2>
+ <replaceable class="PARAMETER">temp2>
of type
- <REPLACEABLE CLASS="PARAMETER">sfunc2_return_type>.
+ <replaceable class="PARAMETER">sfunc2_return_type>.
The arguments to the final-calculation-function
must be
- <REPLACEABLE CLASS="PARAMETER">temp1>
+ <replaceable class="PARAMETER">temp1>
and
- <REPLACEABLE CLASS="PARAMETER">temp2>
+ <replaceable class="PARAMETER">temp2>
and its return value must
base type (not necessarily
- <REPLACEABLE CLASS="PARAMETER">data_type>
+ <replaceable class="PARAMETER">data_type>
which had been specified for BASETYPE).
FINALFUNC should be specified
if and only if both state-transition functions are
specified.
-
-
+
- PARA >
+ para >
An aggregate function may also require one or two initial conditions,
in the database as fields of type text .
- <REFSECT2 ID ="R2-SQL-CREATEAGGREGATE-3">
- <REFSECT2INFO >
- <DATE>1998-09-09>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-SQL-CREATEAGGREGATE-3">
+ <refsect2info >
+ <date>1998-09-09>
+ refsect2info >
+ <title >
Notes
- TITLE >
+ title >
Use DROP AGGREGATE
- to drop aggregate functions.
+ to drop aggregate functions.
- It is possible to specify aggregate functions
- that have varying combinations of state and final functions.
- For example, the count aggregate requires SFUNC2
- (an incrementing function) but not SFUNC1 or FINALFUNC,
- whereas the sum aggregate requires SFUNC1 (an addition
- function) but not SFUNC2 or FINALFUNC and the avg
- 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.
+ It is possible to specify aggregate functions
+ that have varying combinations of state and final functions.
+ For example, the count aggregate requires SFUNC2
+ (an incrementing function) but not SFUNC1 or FINALFUNC,
+ whereas the sum aggregate requires SFUNC1 (an addition
+ function) but not SFUNC2 or FINALFUNC and the avg
+ 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.
-
- REFSECT 2>
+
+ refsect 2>
- <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 PostgreSQL Programmer's Guide
on aggregate functions for
complete examples of usage.
- REFSECT 1>
-
- <REFSECT1 ID ="R1-SQL-CREATEAGGREGATE-3">
- <TITLE >
+ refsect 1>
+
+ <refsect1 id ="R1-SQL-CREATEAGGREGATE-3">
+ <title >
Compatibility
- TITLE >
-
- <REFSECT2 ID ="R2-SQL-CREATEAGGREGATE-4">
- <REFSECT2INFO >
- <DATE>1998-09-09>
- REFSECT2INFO >
- <TITLE >
+ title >
+
+ <refsect2 id ="R2-SQL-CREATEAGGREGATE-4">
+ <refsect2info >
+ <date>1998-09-09>
+ refsect2info >
+ <title >
SQL92
- TITLE >
- <PARA >
+ title >
+ <para >
CREATE AGGREGATE
is a
Postgres language extension.
There is no CREATE AGGREGATE in SQL92.
- PARA >
+ para >
-REFENTRY >
+refentry >
- <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>
- REFSECT2INFO >
- <TITLE >
+ title >
+
+ <refsect2 id ="R2-SQL-CREATEDATABASE-4">
+ <refsect2info >
+ <date>1998-04-15>
+ refsect2info >
+ <title >
SQL92
- TITLE >
- <PARA >
+ title >
+ <para >
There is no CREATE DATABASE statement in SQL92.
- PARA >
+ para >
The equivalent command in standard SQL is CREATE SCHEMA .
-
-
+
- REFSECT 1>
+ refsect 1>
- <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>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-SQL-CREATEINDEX-4">
+ <refsect2info >
+ <date>1998-09-09>
+ refsect2info >
+ <title >
SQL92
- TITLE >
- <PARA >
+ title >
+ <para >
CREATE INDEX is a
Postgres language extension.
- PARA >
+ para >
There is no CREATE INDEX command in SQL92.
-
-
+
-
+
1998-09-11
constraint:
- CREATE ASSERTION name CHECK ( condition )
+CREATE ASSERTION name CHECK ( condition )
Domain constraint:
+
+
+[ CONSTRAINT name ] CHECK constraint
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+
-
- [ CONSTRAINT name ]
- CHECK constraint
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
-
+
Table constraint definition:
+
+
+[ CONSTRAINT name ] { PRIMARY KEY ( column , ... ) | FOREIGN KEY constraint | UNIQUE constraint | CHECK constraint }
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+
-
- [ CONSTRAINT name ]
- { PRIMARY KEY constraint |
- FOREIGN KEY constraint |
- UNIQUE constraint |
- CHECK constraint }
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
+
Column constraint definition:
+
+
+[ CONSTRAINT name ] { NOT NULL | PRIMARY KEY | FOREIGN KEY constraint | UNIQUE | CHECK constraint }
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+
-
- [ CONSTRAINT name ]
- { NOT NULL constraint |
- PRIMARY KEY constraint |
- FOREIGN KEY constraint |
- UNIQUE constraint |
- CHECK constraint }
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
-
+
A CONSTRAINT definition may contain one deferment attribute
clause and/or one initial constraint mode clause, in any order.
-->
table constraint definition:
-
-
- [ CONSTRAINT name ]
- CHECK ( VALUE condition )
+
+[ CONSTRAINT name ] CHECK ( VALUE condition )
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
[ [ NOT ] DEFERRABLE ]
-
+
+
+
column constraint definition:
-
- [ CONSTRAINT name ]
- CHECK ( VALUE condition )
+[ CONSTRAINT name ] CHECK ( VALUE condition )
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
[ [ NOT ] DEFERRABLE ]
+
-
-
+
1998-09-11
Table Constraint definition:
+
+[ CONSTRAINT name ] PRIMARY KEY ( column [, ...] )
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+
-
- [ CONSTRAINT name ]
- PRIMARY KEY ( column [, ...] )
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
-
Column Constraint definition:
+
+[ CONSTRAINT name ] PRIMARY KEY
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
+
-
- [ CONSTRAINT name ]
- PRIMARY KEY
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
-
-
- table
-
+ table
The name of a new table to be created.
-
- column
-
-
- The name of a column. Multiple column names can be specified using
-a comma-delimited list of column names.
-
-
-
-
-
-
- select_clause
-
-
-A valid query statement. Refer to SELECT for a description of the
-allowed syntax.
+ column
+
+ The name of a column. Multiple column names can be specified using
+ a comma-delimited list of column names.
+
+
+
+
+
+ select_clause
+
+ A valid query statement. Refer to SELECT for a description of the
+ allowed syntax.
Outputs
- Refer to CREATE TABLE and SELECT for a summary of possible output
+ Refer to CREATE TABLE
+ and SELECT for a summary of possible output
messages.
Description
-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.
+ 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 direct syntax.
-<REFENTRY ID ="SQL-CREATETRIGGER">
- <REFMETA >
- <REFENTRYTITLE >
+<refentry id ="SQL-CREATETRIGGER">
+ <refmeta >
+ <refentrytitle >
CREATE TRIGGER
- REFENTRYTITLE >
- <REFMISCINFO>SQL - Language Statements>
- REFMETA >
- <REFNAMEDIV >
- <REFNAME >
+ refentrytitle >
+ <refmiscinfo>SQL - Language Statements>
+ refmeta >
+ <refnamediv >
+ <refname >
CREATE TRIGGER
- REFNAME >
- <REFPURPOSE >
+ refname >
+ <refpurpose >
Creates a new trigger
- REFPURPOSE >
+ refpurpose >
-
-
- 1998-09-21
-
-
-CREATE TRIGGER name { BEFORE | AFTER }
- { event [OR ...] }
- ON table FOR EACH { ROW | STATEMENT }
- EXECUTE PROCEDURE funcname ( arguments )
-
+
+
+ 1998-09-21
+
+
+CREATE TRIGGER name { BEFORE | AFTER } { event [OR ...] }
+ ON table FOR EACH { ROW | STATEMENT }
+ EXECUTE PROCEDURE ER">func BLE> ( arguments )
+
- <REFSECT2 ID ="R2-SQL-CREATETRIGGER-1">
- <REFSECT2INFO >
- <DATE>1998-09-21>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-SQL-CREATETRIGGER-1">
+ <refsect2info >
+ <date>1998-09-21>
+ refsect2info >
+ <title >
Inputs
-
-
-
-
-
- name
-
-
- The name of an existing trigger.
-
-
-
-
-
- table
-
-
- The name of a table.
-
-
-
-
-
- event
-
-
- One of INSERT, DELETE or UPDATE.
-
-
-
-
-
- funcname
-
-
- A user-supplied function.
-
-
-
-
-
-
-
-
- 1998-09-21
-
-
+
+
+
+
+ name
+
+ The name of an existing trigger.
+
+
+
+
+ table
+
+ The name of a table.
+
+
+
+
+ event
+
+ One of INSERT, DELETE or UPDATE.
+
+
+
+
+ funcname
+
+ A user-supplied function.
+
+
+
+
+
+
+
+
+
+ 1998-09-21
+
+
Outputs
-
-
-
-
- CREATE
-
-
- This message is returned if the trigger is successfully created.
+
+
+
+
+
+CREATE
+
+
+ This message is returned if the trigger is successfully created.
- VARIABLELIST >
+ variablelist >
- REFSECT 2>
- REFSYNOPSISDIV >
+ refsect 2>
+ refsynopsisdiv >
- <REFSECT1 ID ="R1-SQL-CREATETRIGGER-1">
- <REFSECT1INFO >
- <DATE>1998-09-21>
- REFSECT1INFO >
- <TITLE >
+ <refsect1 id ="R1-SQL-CREATETRIGGER-1">
+ <refsect1info >
+ <date>1998-09-21>
+ refsect1info >
+ <title >
Description
- TITLE >
- <PARA >
+ title >
+ <para >
CREATE TRIGGER will enter a new trigger into the current
data base. The trigger will be associated with the relation
relname and will execute
the specified function funcname .
- 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
PostgreSQL Programmer's Guide for more
information.
- PARA >
- <REFSECT2 ID ="R2-SQL-CREATETRIGGER-3">
- <REFSECT2INFO >
- <DATE>1998-09-21>
- REFSECT2INFO >
- <TITLE >
+ para >
+ <refsect2 id ="R2-SQL-CREATETRIGGER-3">
+ <refsect2info >
+ <date>1998-09-21>
+ refsect2info >
+ <title >
Notes
- TITLE >
- <PARA >
+ title >
+ <para >
CREATE TRIGGER is a
Postgres
language extension.
- PARA >
- Only the relation owner may create a trigger on this relation.
- >
- As of the current release (v6.4), STATEMENT triggers are not implemented.
- >
- <PARA >
+ para >
+ Only the relation owner may create a trigger on this relation.
+ >
+ As of the current release (v6.4), STATEMENT triggers are not implemented.
+ >
+ <para >
Refer to DROP TRIGGER for information on how to
remove triggers.
- PARA >
- REFSECT 2>
+ para >
+ refsect 2>
- <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:
-
- CREATE TRIGGER if_dist_exists
- BEFORE INSERT OR UPDATE ON films FOR EACH ROW
- EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
-
+
+CREATE TRIGGER if_dist_exists
+ BEFORE INSERT OR UPDATE ON films FOR EACH ROW
+ EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
+
+
Before cancelling a distributor or updating its code, remove every
reference to the table films:
- >
- 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 >
- REFSECT 1>
-
- <REFSECT1 ID ="R1-SQL-CREATETRIGGER-3">
- <TITLE >
+CREATE TRIGGER if_film_exists
+ BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
+ EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
+
+ para >
+ refsect 1>
+
+ <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>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-SQL-CREATETRIGGER-4">
+ <refsect2info >
+ <date>1998-09-21>
+ refsect2info >
+ <title >
SQL92
- TITLE >
- <PARA >
+ title >
+ <para >
There is no
CREATE TRIGGER in
SQL92 .
-
+
+
The second example above may also be done by using a FOREIGN KEY
constraint as in:
-
- CREATE TABLE distributors (
+
+CREATE TABLE distributors (
did DECIMAL(3),
name VARCHAR(40),
CONSTRAINT if_film_exists
FOREIGN KEY(did) REFERENCES films
ON UPDATE CASCADE ON DELETE CASCADE
- );
-
+);
+
+
+
However, foreign keys are not yet implemented (as of version 6.4) in
- PARA >
+ para >
-REFENTRY >
+refentry >
-<REFENTRY ID ="APP-CREATEUSER">
->
->
->
-Application >
->
->
->
->
->
-Create a new
Postgres user
->
-
->
->
-1998-10-02 >
->
->
+<refentry id ="APP-CREATEUSER">
+ >
+ >
+ >
+ Application >
+ >
+ >
+ >
+ >
+ >
+
Create a new
Postgres user
+ >
+
+ >
+ >
+ 1998-10-02 >
+ >
+ >
createuser [ username ]
createuser [ -h host ] [ -p port ]
- [ -i userid ]
- [ -d | -D ] [ -u | -U ] [ username ]
->
+ [ -i userid ] [ -d | -D ] [ -u | -U ]
+ [ username ]
+ >
-
-
- 1998-10-02
-
-
- Inputs
-
-
-
-
-
- -h host
-
-
- Specifies the hostname of the machine on which the
- is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-
-
-
-
-
- -p port
-
-
- Specifies the Internet TCP/IP port or local Unix domain socket file
- extension on which the
postmaster
- is listening for connections. The port number defaults to 5432,
- or the value of the PGPORT
- environment variable (if set).
-
-
-
-
-
-
- -d
-
-
- Allows the user to create databases.
-
-
-
-
-
-
- -D
-
-
- Forbids the user to create databases.
-
-
-
-
-
-
- -i userid
-
-
- Specifies the numeric identifier to be associated with this user.
- This identifier must be unique among all
Postgres 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.
-
-
-
-
-
-
- -u
-
-
- Allows the user to create other users.
-
-
-
-
-
-
- -U
-
-
- Forbids the user to create other users.
-
-
-
-
-
-
- username
-
-
- Specifies the name of the
Postgres user to be created.
- This name must be unique among all
Postgres users.
- You will be prompted for a name if none is specified on the command line.
-
-
-
-
-
-
-
+
+
+ 1998-10-02
+
+
+ Inputs
+
-
-
- 1998-10-02
-
-
- Outputs
-
-
createuser will add an entry in the
- pg_user or pg_shadow system table.
-
-
-
-
- Connection to database 'template1' failed.
- connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port 'port '?
- createuser: database access failed.
-
-
-
createuser could not attach to the
- process on the specified host and port. If you see this message,
- ensure that the
postmaster
- 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.
-
-
-
-
-
-
- Connection to database 'template1' failed.
- FATAL 1: SetUserId: user 'username ' is not in 'pg_shadow'
- createuser: database access failed.
-
-
- You do not have a valid entry in the relation pg_shadow
- and and will not be allowed to access
Postgres . Contact your
-
Postgres administrator.
-
-
-
-
-
-
- createuser: username cannot create users.
-
-
- You do not have permission to create new users; contact your
-
Postgres site administrator.
-
-
-
-
-
-
- createuser: user "username " already exists
-
-
- The user to be added already has an entry in the pg_shadow
- class.
-
-
-
-
-
-
- database access failed
-
-
- An internal error occurred in
psql
- or in the backend server. Ensure that your site administrator has
- properly installed
Postgres and initialized the site with
-
-
-
-
-
-
-
-
-
createuser internally runs
- while connected to the template1 database.
-
-
-
-
-
-
-
- 1998-10-02
-
-
- Description
-
- Only users with usesuper set in
- the pg_shadow class can create
- new
Postgres users. As shipped,
- the user postgres can create users.
-
+
+
+ -h host
+
+ Specifies the hostname of the machine on which the
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection.
+
+
+
+
+
+ -p port
+
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the
postmaster
+ is listening for connections. The port number defaults to 5432,
+ or the value of the PGPORT
+ environment variable (if set).
+
+
+
+
+
+ -d
+
+ Allows the user to create databases.
+
+
+
+
+
+ -D
+
+ Forbids the user to create databases.
+
+
+
+
+
+ -i userid
+
+ Specifies the numeric identifier to be associated with this user.
+ This identifier must be unique among all
+
Postgres 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.
+
+
+
+
+
+ -u
+
+ Allows the user to create other users.
+
+
+
+
+
+ -U
+
+ Forbids the user to create other users.
+
+
+
+
+
+ username
+
+ Specifies the name of the
Postgres user to be created.
+ This name must be unique among all
Postgres users.
+ You will be prompted for a name if none is specified on the command line.
+
+
+
+
+
+
+
+
+
+ 1998-10-02
+
+
+ Outputs
+
+
createuser will add an entry in the
+ pg_user or pg_shadow system table.
+
+
+
+
+Connection to database 'template1' failed.
+connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port 'port '?
+createuser: database access failed.
+
+
+
createuser could not attach to the
+ process on the specified host and port. If you see this message,
+ ensure that the
postmaster
+ 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.
+
+
+
+
+
+
+Connection to database 'template1' failed.
+FATAL 1: SetUserId: user 'username ' is not in 'pg_shadow'
+createuser: database access failed.
+
+
+ You do not have a valid entry in the relation pg_shadow
+ and and will not be allowed to access
Postgres . Contact your
+
Postgres administrator.
+
+
+
+
+
+
+createuser: username cannot create users.
+
+
+ You do not have permission to create new users; contact your
+
Postgres site administrator.
+
+
+
+
+
+
+createuser: user "username " already exists
+
+
+ The user to be added already has an entry in the
+ pg_shadow class.
+
+
+
+
+
+
+database access failed
+
+
+ An internal error occurred in
psql
+ or in the backend server. Ensure that your site administrator has
+ properly installed
Postgres and initialized the site with
+
+
+
+
+
+
+
-
createuser is a shell script that invokes
- process must be running on the database server host before
-
createuser is executed.
- The
- PGOPTION
- and
- PGREALM
- environment variables will be passed on to
- and processed as described in .
-
- Once invoked,
createuser
- 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.
+
createuser internally runs
+ while connected to the template1 database.
-
- The
Postgres user identifier
- does not need to be the same as the user's Unix UID. However, typically
- they are assigned to be the same.
-
-
-
+
+
+
+
+
+
+ 1998-10-02
+
+
+ Description
+
+ Only users with usesuper set in
+ the pg_shadow class can create
+ new
Postgres users. As shipped,
+ the user postgres can create users.
+
+
createuser is a shell script that invokes
+ process must be running on the database server host before
+
createuser is executed.
+ The
+ PGOPTION
+ and
+ PGREALM
+ environment variables will be passed on to
+ and processed as described in .
+
+
+ Once invoked,
createuser
+ 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.
+
+
- 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
Postgres super-user,
- whether the new user may create new databases and whether the new user
- is allowed to create other new users.
+ The
Postgres user identifier
+ does not need to be the same as the user's Unix UID. However, typically
+ they are assigned to be the same.
-
-
+
+
+
+ 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
Postgres super-user,
+ whether the new user may create new databases and whether the new user
+ is allowed to create other new users.
+
+
+
+
+
-<REFENTRY ID ="SQL-DECLARE">
- <REFMETA >
- <REFENTRYTITLE >
+<refentry id ="SQL-DECLARE">
+ <refmeta >
+ <refentrytitle >
DECLARE
- REFENTRYTITLE >
- <REFMISCINFO>SQL - Language Statements>
- REFMETA >
- <REFNAMEDIV >
- <REFNAME >
+ refentrytitle >
+ <refmiscinfo>SQL - Language Statements>
+ refmeta >
+ <refnamediv >
+ <refname >
DECLARE
- REFNAME >
- <REFPURPOSE >
+ refname >
+ <refpurpose >
Defines a cursor for table access
- REFPURPOSE >
+ refpurpose >
- <REFSYNOPSISDIV >
- <REFSYNOPSISDIVINFO >
- <DATE>1998-09-04>
- REFSYNOPSISDIVINFO >
- <SYNOPSIS >
+ <refsynopsisdiv >
+ <refsynopsisdivinfo >
+ <date>1998-09-04>
+ refsynopsisdivinfo >
+ <synopsis >
DECLARE cursor [ BINARY ] [ INSENSITIVE ] [ SCROLL ]
CURSOR FOR query
[ FOR { READ ONLY | UPDATE [ OF column [, ...] ] ]
- SYNOPSIS >
- <REFSECT2 ID ="R2-SQL-DECLARE-1">
- <REFSECT2INFO >
- <DATE>1998-04-15>
- REFSECT2INFO >
- <TITLE >
+ synopsis >
+ <refsect2 id ="R2-SQL-DECLARE-1">
+ <refsect2info >
+ <date>1998-04-15>
+ refsect2info >
+ <title >
Inputs
-
-
-
-
-
- cursor
-
-
- The name of the cursor to be used in subsequent FETCH operations..
-
-
-
+
+
+
+ cursor
+
+ The name of the cursor to be used in subsequent FETCH operations..
+
+
+
-
-
- BINARY
-
-
- Causes the cursor to fetch data in binary
- rather than in text format.
-
-
-
+
+ BINARY
+
+ Causes the cursor to fetch data in binary
+ rather than in text format.
+
+
+
-
-
- INSENSITIVE
-
-
-
SQL92 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
Postgres this is always the case.
-This keyword has no effect.
-
-
-
+
+ INSENSITIVE
+
+
SQL92 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
Postgres this is always the case.
+ This keyword has no effect.
+
+
+
-
-
- SCROLL
-
-
-
SQL92 keyword indicating that data may be retrieved
-in multiple rows per FETCH operation. Since this is allowed at all times
-by
Postgres this keyword has no effect.
-
-
-
+
+ SCROLL
+
+
SQL92 keyword indicating that data may be retrieved
+ in multiple rows per FETCH operation. Since this is allowed at all times
+ by
Postgres this keyword has no effect.
+
+
+
-
-
- query
-
-
- 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.
-
-
-
+
+ query
+
+ 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.
+
+
+
-
-
- READ ONLY
-
-
-
SQL92 keyword indicating that the cursor will be used
-in a readonly mode. Since this is the only cursor access mode
-available in
Postgres this keyword has no effect.
-
-
-
+
+ READ ONLY
+
+
SQL92 keyword indicating that the cursor will be used
+ in a readonly mode. Since this is the only cursor access mode
+ available in
Postgres this keyword has no effect.
+
+
+
-
-
- UPDATE
-
-
-
SQL92 keyword indicating that the cursor will be used
-to update tables. Since cursor updates are not currently
-supported in
Postgres this keyword
-provokes an informational error message.
-
-
-
+
+ UPDATE
+
+
SQL92 keyword indicating that the cursor will be used
+ to update tables. Since cursor updates are not currently
+ supported in
Postgres this keyword
+ provokes an informational error message.
+
+
+
-
-
- column
-
-
-Column(s) to be updated.
-Since cursor updates are not currently
-supported in
Postgres the UPDATE clause
-provokes an informational error message.
-
-
-
+
+ column
+
+ Column(s) to be updated.
+ Since cursor updates are not currently
+ supported in
Postgres the UPDATE clause
+ provokes an informational error message.
+
+
+
-
-
+
+
+
- <REFSECT2 ID ="R2-SQL-DECLARE-2">
- <REFSECT2INFO >
- <DATE>1998-04-15>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-SQL-DECLARE-2">
+ <refsect2info >
+ <date>1998-04-15>
+ refsect2info >
+ <title >
Outputs
- TITLE >
- <PARA >
+ title >
+ <para >
- >
- >
- >
- SELECT
- >
- >
- The message returned if the SELECT is run successfully.
- >
- >
- >
+ >
+ >
+ >
+SELECT
+ >
+ >
+ The message returned if the SELECT is run successfully.
+ >
+ >
+ >
- >
- >
- NOTICE
- BlankPortalAssignName: portal "cursor " already exists
- >
- >
- This error occurs if cursor "cursor " is already declared.
- >
- >
- >
+ >
+ >
+NOTICE
+BlankPortalAssignName: portal "cursor " already exists
+ >
+ >
+ This error occurs if cursor is already declared.
+ >
+ >
+ >
- >
- >
+ >
+ >
ERROR: Named portals may only be used in begin/end transaction blocks
- >
- >
-This error occurs if the cursor is not declared within a transaction block.
- PARA >
- LISTITEM >
- VARLISTENTRY >
- VARIABLELIST >
+ >
+ >
+ This error occurs if the cursor is not declared within a transaction block.
+ para >
+ listitem >
+ varlistentry >
+ variablelist >
- REFSECT 2>
- REFSYNOPSISDIV >
-
- <REFSECT1 ID ="R1-SQL-DECLARE-1">
- <REFSECT1INFO >
- <DATE>1998-09-04>
- REFSECT1INFO >
- <TITLE >
+ refsect 2>
+ refsynopsisdiv >
+
+ <refsect1 id ="R1-SQL-DECLARE-1">
+ <refsect1info >
+ <date>1998-09-04>
+ refsect1info >
+ <title >
Description
- TITLE >
- <PARA >
- DECLARE allows a user to create cursors, which can be used to retrieve
+ title >
+ <para >
+ DECLARE 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.
-
+
+
Normal cursors return data in text format, either ASCII or another
-encoding scheme depending on how the
Postgres
-backend was built. Since
+
encoding scheme depending on how the
Postgres
+ 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.
-
+
+
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.
+
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').
+
BINARY cursors should be used carefully. User applications such
+
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.
-
+
If you intend to display the data in
effort on the client side.
- PARA >
-
- <REFSECT2 ID ="R2-SQL-DECLARE-3">
- <REFSECT2INFO >
- <DATE>1998-09-04>
- REFSECT2INFO >
- <TITLE >
+ para >
+
+ <refsect2 id ="R2-SQL-DECLARE-3">
+ <refsect2info >
+ <date>1998-09-04>
+ refsect2info >
+ <title >
Notes
- TITLE >
- <PARA >
+ title >
+ <para >
Cursors are only available in transactions.
- PARA >
- <PARA >
+ para >
+ <para >
does not have an explicit OPEN cursor
statement; a cursor is considered to be open when it is declared.
-
+
In
SQL92 cursors are only available in
involving DECLARE and OPEN statements.
-
-
-
+
+
-
- <REFSECT1 ID ="R1-SQL-DECLARESTATEMENT-2">
- <TITLE >
+
+ <refsect1 id ="R1-SQL-DECLARESTATEMENT-2">
+ <title >
Usage
- TITLE >
- <PARA >
+ title >
+ <para >
To declare a cursor:
-
+
DECLARE liahona CURSOR
FOR SELECT * FROM films;
-
-
+
+
+
- <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>
- REFSECT2INFO >
- <TITLE >
+ title >
+ <para >
+ para >
+
+ <refsect2 id ="R2-SQL-DECLARESTATEMENT-4">
+ <refsect2info >
+ <date>1998-04-15>
+ refsect2info >
+ <title >
SQL92
- TITLE >
- <PARA >
+ title >
+ <para >
SQL92 allows cursors only in embedded
SQL
and in modules.
Postgres permits cursors to be used
interactively.
-REFENTRY >
+refentry >
-<REFENTRY ID ="APP-DESTROYUSER">
->
->
->
-Application >
->
->
->
->
->
-Destroy a
Postgres user and associated databases
->
-
->
->
-1998-10-02 >
->
->
+<refentry id ="APP-DESTROYUSER">
+ >
+ >
+ >
+ Application >
+ >
+ >
+ >
+ >
+ >
+
Destroy a
Postgres user and associated databases
+ >
+
+ >
+ >
+ 1998-10-02 >
+ >
+ >
destroyuser [ username ]
destroyuser [ -h host ] [ -p port ]
[ username ]
->
+ >
-
-
- 1998-10-02
-
-
- Inputs
-
-
-
-
-
- -h host
-
-
- Specifies the hostname of the machine on which the
- is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-
-
-
-
-
- -p port
-
-
- Specifies the Internet TCP/IP port or local Unix domain socket file
- extension on which the
postmaster
- is listening for connections. The port number defaults to 5432,
- or the value of the PGPORT
- environment variable (if set).
-
-
-
-
-
-
- username
-
-
- Specifies the name of the
Postgres user to be removed.
- This name must exist in the
Postgres installation.
- You will be prompted for a name if none is specified on the command line.
-
-
-
-
-
-
-
-
-
-
- 1998-10-02
-
-
- Outputs
-
-
destroyuser will remove an entry in the
- pg_user or pg_shadow system table,
- and will remove all databases for which that user is the administrator
+
+
+ 1998-10-02
+
+
+ Inputs
+
-
-
-
- Connection to database 'template1' failed.
- connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port 'port '?
- destroyuser: database access failed.
-
-
-
destroyuser could not attach to the
- process on the specified host and port. If you see this message,
- ensure that the
postmaster
- 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.
-
-
-
-
-
-
- Connection to database 'template1' failed.
- FATAL 1: SetUserId: user 'username ' is not in 'pg_shadow'
- destroyuser: database access failed.
-
-
- You do not have a valid entry in the relation pg_shadow
- and and will not be allowed to access
Postgres . Contact your
-
Postgres administrator.
-
-
-
-
-
-
- destroyuser: username cannot delete users.
-
-
- You do not have permission to delete users; contact your
-
Postgres site administrator.
-
-
-
+
+
+ -h host
+
+ Specifies the hostname of the machine on which the
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection.
+
+
+
-
-
- destroyuser: user "username " already exists
-
-
- The user to be added already has an entry in the pg_shadow
- class.
-
-
-
-
-
-
- database access failed
-
-
- An internal error occurred in
psql
- or in the backend server. Ensure that your site administrator has
- properly installed
Postgres and initialized the site with
-
-
-
+
+ -p port
+
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the
postmaster
+ is listening for connections. The port number defaults to 5432,
+ or the value of the PGPORT
+ environment variable (if set).
+
+
+
-
-
- destroydb on dbname failed - exiting
-
-
- An internal error occurred in
psql
- or in the backend server. There was possibly a Unix permissions problem with the
- specified database.
-
-
-
+
+ username
+
+ Specifies the name of the
Postgres user to be removed.
+ This name must exist in the
Postgres installation.
+ You will be prompted for a name if none is specified on the command line.
+
+
+
+
+
+
-
-
- delete of user username was UNSUCCESSFUL
-
-
- An internal error occurred in
psql
- or in the backend server.
-
-
-
+
+
+ 1998-10-02
+
+
+ Outputs
+
+
destroyuser will remove an entry in the
+ pg_user or pg_shadow system table,
+ and will remove all databases for which that user is the administrator
-
-
+
+
+
+Connection to database 'template1' failed.
+connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port 'port '?
+destroyuser: database access failed.
+
+
+
destroyuser could not attach to the
+ process on the specified host and port. If you see this message,
+ ensure that the
postmaster
+ 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.
+
+
+
-
-
destroyuser internally runs
- while connected to the template1 database.
-
-
-
-
-
-
-
- 1998-10-02
-
-
- Description
-
-
destroyuser removes an existing
- and the databases for which that user
- is database administrator.
- Only users with usesuper set in
- the pg_shadow class can destroy
-
Postgres users. As shipped,
- the user postgres can remove users.
-
-
destroyuser is a shell script that invokes
- process must be running on the database server host before
-
destroyuser is executed.
- The
- PGOPTION
- and
- PGREALM
- environment variables will be passed on to
- and processed as described in .
-
+
+
+Connection to database 'template1' failed.
+FATAL 1: SetUserId: user 'username ' is not in 'pg_shadow'
+destroyuser: database access failed.
+
+
+ You do not have a valid entry in the relation pg_shadow
+ and and will not be allowed to access
Postgres . Contact your
+
Postgres administrator.
+
+
+
+
+
+
+destroyuser: username cannot delete users.
+
+
+ You do not have permission to delete users; contact your
+
Postgres site administrator.
+
+
+
+
+
+
+destroyuser: user "username " already exists
+
+
+ The user to be added already has an entry in the
+ pg_shadow class.
+
+
+
+
+
+
+database access failed
+
+
+ An internal error occurred in
psql
+ or in the backend server. Ensure that your site administrator has
+ properly installed
Postgres and initialized the site with
+
+
+
+
+
+
+destroydb on dbname failed - exiting
+
+
+ An internal error occurred in
psql
+ or in the backend server. There was possibly a Unix permissions problem with the
+ specified database.
+
+
+
+
+
+
+delete of user username was UNSUCCESSFUL
+
+
+ An internal error occurred in
psql
+ or in the backend server.
+
+
+
+
+
+
+
- Once invoked,
destroyuser
- 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 .
+
destroyuser internally runs
+ while connected to the template1 database .
-
-
+
+
+
+
+
+
+ 1998-10-02
+
+
+ Description
+
+
destroyuser removes an existing
+ and the databases for which that user
+ is database administrator.
+ Only users with usesuper set in
+ the pg_shadow class can destroy
+
Postgres users. As shipped,
+ the user postgres can remove users.
+
+
destroyuser is a shell script that invokes
+ process must be running on the database server host before
+
destroyuser is executed.
+ The
+ PGOPTION
+ and
+ PGREALM
+ environment variables will be passed on to
+ and processed as described in
+ linkend="app-psql">.
+
+ Once invoked,
destroyuser
+ 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.
+
+
+
+
+
-<REFENTRY ID ="SQL-DROPAGGREGATE">
- <REFMETA >
- <REFENTRYTITLE >
+<refentry id ="SQL-DROPAGGREGATE">
+ <refmeta >
+ <refentrytitle >
DROP AGGREGATE
- REFENTRYTITLE >
- <REFMISCINFO>SQL - Language Statements>
- REFMETA >
- <REFNAMEDIV >
- <REFNAME >
+ refentrytitle >
+ <refmiscinfo>SQL - Language Statements>
+ refmeta >
+ <refnamediv >
+ <refname >
DROP AGGREGATE
- REFNAME >
- <REFPURPOSE >
+ refname >
+ <refpurpose >
Removes the definition of an aggregate function
- REFPURPOSE >
+ refpurpose >
- <REFSYNOPSISDIV >
- <REFSYNOPSISDIVINFO >
- <DATE>1998-04-15>
- REFSYNOPSISDIVINFO >
- <SYNOPSIS >
-DROP AGGREGATE <REPLACEABLE CLASS="PARAMETER">name type >
- SYNOPSIS >
-
- <REFSECT2 ID ="R2-SQL-DROPAGGREGATE-1">
- <REFSECT2INFO >
- <DATE>1998-04-15>
- REFSECT2INFO >
- <TITLE >
+ <refsynopsisdiv >
+ <refsynopsisdivinfo >
+ <date>1998-04-15>
+ refsynopsisdivinfo >
+ <synopsis >
+DROP AGGREGATE <replaceable class="PARAMETER">name type >
+ synopsis >
+
+ <refsect2 id ="R2-SQL-DROPAGGREGATE-1">
+ <refsect2info >
+ <date>1998-04-15>
+ refsect2info >
+ <title >
Inputs
-
-
-
-
-
- name
-
-
- The name of an existing aggregate function.
-
-
-
-
-
- type
-
-
- The type of an existing aggregate function.
- (Refer to the PostgreSQL User's Guide for
- further information about data types).
- This should become a cross-reference rather than a
- hard-coded chapter number
-
-
-
-
-
-
-
-
- 1998-04-15
-
-
+
+
+
+ name
+
+ The name of an existing aggregate function.
+
+
+
+
+ type
+
+ The type of an existing aggregate function.
+ (Refer to the PostgreSQL User's Guide for
+ further information about data types).
+ This should become a cross-reference rather than a
+ hard-coded chapter number
+
+
+
+
+
+
+
+
+
+ 1998-04-15
+
+
Outputs
- TITLE >
- <PARA >
- >
- >
- >
- DROP
- >
- >
- Message returned if the command is successful.
- >
- >
- >
- >
- >
- WARN RemoveAggregate: aggregate 'name ' for 'type ' does not exist
- >
- >
- This message occurs if the aggregate function specified does not
- exist in the database.
+ title >
+ <para >
+ >
+ >
+ >
+DROP
+ >
+ >
+ Message returned if the command is successful.
+ >
+ >
+ >
+ >
+ >
+WARN RemoveAggregate: aggregate 'agg ' for 'type ' does not exist
+ >
+ >
+ This message occurs if the aggregate function specified does not
+ exist in the database.
- VARIABLELIST >
+ variablelist >
- REFSECT 2>
- REFSYNOPSISDIV >
-
- <REFSECT1 ID ="R1-SQL-DROPAGGREGATE-1">
- <REFSECT1INFO >
- <DATE>1998-04-15>
- REFSECT1INFO >
- <TITLE >
+ refsect 2>
+ refsynopsisdiv >
+
+ <refsect1 id ="R1-SQL-DROPAGGREGATE-1">
+ <refsect1info >
+ <date>1998-04-15>
+ refsect1info >
+ <title >
Description
- TITLE >
- <PARA >
+ title >
+ <para >
DROP AGGREGATE 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>
- REFSECT2INFO >
- <TITLE >
+ para >
+
+ <refsect2 id ="R2-SQL-DROPAGGREGATE-3">
+ <refsect2info >
+ <date>1998-04-15>
+ refsect2info >
+ <title >
Notes
- TITLE >
- <PARA >
+ title >
+ <para >
The DROP AGGREGATE statement is a
language extension.
- PARA >
- <PARA >
+ para >
+ <para >
Refer to the CREATE AGGREGATE statement to
create aggregate functions.
- PARA >
- REFSECT 2>
- REFSECT 1>
-
- <REFSECT1 ID ="R1-SQL-DROPAGGREGATE-2">
- <TITLE >
+ para >
+ refsect 2>
+ refsect 1>
+
+ <refsect1 id ="R1-SQL-DROPAGGREGATE-2">
+ <title >
Usage
- TITLE >
- <PARA >
+ title >
+ <para >
To remove the myavg aggregate for type
int4 :
- PARA >
- <ProgramL isting>
+ para >
+ <programl isting>
DROP AGGREGATE myavg int4;
- ProgramL isting>
- REFSECT 1>
-
- <REFSECT1 ID ="R1-SQL-DROPAGGREGATE-3">
- <TITLE >
+ programl isting>
+ refsect 1>
+
+ <refsect1 id ="R1-SQL-DROPAGGREGATE-3">
+ <title >
Compatibility
- TITLE >
- <PARA >
- PARA >
-
- <REFSECT2 ID ="R2-SQL-DROPAGGREGATE-4">
- <REFSECT2INFO >
- <DATE>1998-04-15>
- REFSECT2INFO >
- <TITLE >
+ title >
+ <para >
+ para >
+
+ <refsect2 id ="R2-SQL-DROPAGGREGATE-4">
+ <refsect2info >
+ <date>1998-04-15>
+ refsect2info >
+ <title >
SQL92
- TITLE >
- <PARA >
- There is no DROP AGGREGATE statement in
SQL92 .
- PARA >
+ title >
+ <para >
+
There is no DROP AGGREGATE statement in
SQL92 .
+ para >
-REFENTRY >
+refentry >
+
-
-
-
-FETCH
-
-SQL - Language Statements
-
-
-
-FETCH
-
-
-Gets rows using a cursor
-
-
-
-
-1998-09-01
-
-
-FETCH [ selector ] [ count ]
- { IN | FROM } cursor
-FETCH [ RELATIVE ] [ { [ # | ALL | NEXT | PRIOR ] } ]
- FROM ] cursor
-
-
-
-
-1998-09-01
-
-
-Inputs
-
-
-
-
-
-selector
-
-
-selector
-defines the fetch direction. It can be one
- the following:
-
-
-
-
-
-
-
-FORWARD
-
-
-fetch next row(s). This is the default
- if selector is omitted.
-
-
-
-
-
-BACKWARD
-
-
-fetch previous row(s).
-
-
-
-
-
-RELATIVE
-
-
-Noise word for SQL92 compatibility.
-
-
-
-
-
-
-
-count
-
-
-count
-determines how many rows to fetch. It can be one of the following:
-
-
-
-
-
-
-
-#
-
-
-A signed integer that specify how many rows to fetch.
-Note that a negative integer is equivalent to changing the sense of
-FORWARD and BACKWARD.
-
-
-
-
-
-
-ALL
-
-
-Retrieve all remaining rows.
-
-
-
-
-
-
-NEXT
-
-
-Equivalent to specifying a count of 1 .
-
-
-
-
-
-
-PRIOR
-
-
-Equivalent to specifying a count of -1 .
-
-
-
-
-
-
-cursor
-
-
-An open cursor's name.
-
-
-
-
-
-
-
-
-
-1998-04-15
-
-
-Outputs
-
-FETCH returns the results of the query defined by the specified cursor.
-The following messages will be returned if the query fails:
-
-
-
-
-
-NOTICE: PerformPortalFetch: portal "cursor " not found
-
-
-If cursor
- is not previously declared.
-The cursor must be declared within a transaction block.
-
-
-
-
-
-
+
+
+
+ FETCH
+
+ SQL - Language Statements
+
+
+
+ FETCH
+
+
+ Gets rows using a cursor
+
+
+
+
+ 1998-09-01
+
+
+FETCH [ selector ] [ count ] { IN | FROM } cursor
+FETCH [ RELATIVE ] [ { [ # | ALL | NEXT | PRIOR ] } ] FROM ] cursor
+
+
+
+
+ 1998-09-01
+
+
+ Inputs
+
+
+
+
+ selector
+
+ selector
+ defines the fetch direction. It can be one
+ the following:
+
+
+
+ FORWARD
+
+ fetch next row(s). This is the default
+ if selector is omitted.
+
+
+
+
+ BACKWARD
+
+ fetch previous row(s).
+
+
+
+
+ RELATIVE
+
+ Noise word for SQL92 compatibility.
+
+
+
+
+
+
+
+
+
+ count
+
+ count
+ determines how many rows to fetch. It can be one of the following:
+
+
+
+ #
+
+ A signed integer that specify how many rows to fetch.
+ Note that a negative integer is equivalent to changing the sense of
+ FORWARD and BACKWARD.
+
+
+
+
+
+
+ ALL
+
+
+ Retrieve all remaining rows.
+
+
+
+
+
+
+ NEXT
+
+
+ Equivalent to specifying a count of 1 .
+
+
+
+
+
+
+ PRIOR
+
+
+ Equivalent to specifying a count of -1 .
+
+
+
+
+
+
+
+
+
+ cursor
+
+ An open cursor's name.
+
+
+
+
+
+
+
+
+
+ 1998-04-15
+
+
+ Outputs
+
+ FETCH returns the results of the query defined by the specified cursor.
+ The following messages will be returned if the query fails:
+
+
+
+
+NOTICE: PerformPortalFetch: portal "cursor " not found
+
+
+ If cursor
+ is not previously declared.
+ The cursor must be declared within a transaction block.
+
+
+
+
+
+
NOTICE: FETCH/ABSOLUTE not supported, using RELATIVE
->
->
-
Postgres does not support absolute
-positioning of cursors.
-
-
-
-
->
->
+ >
+ >
+
Postgres does not support absolute
+ positioning of cursors.
+
+
+
+
+ >
+ >
ERROR: FETCH/RELATIVE at current position is not supported
-
-
-
SQL92 allows one to repetatively retrieve the cursor
-at its "current position" using the syntax
-FETCH RELATIVE 0 FROM cursor
-
-
-
Postgres does not currently support
-this notion; in fact the value zero is reserved to indicate that
-all rows should be retrieved and is equivalent to specifying the ALL keyword.
-If the RELATIVE keyword has been used, the
Postgres
-assumes that the user intended
SQL92 behavior
-and returns this error message.
-
-
-
-
-
-
-
-
-
-
-
-1998-04-15
-
-
-Description
-
+
+
+
SQL92 allows one to repetatively retrieve the cursor
+ at its "current position" using the syntax
+
+FETCH RELATIVE 0 FROM cursor
+
+
+
+
Postgres does not currently support
+ this notion; in fact the value zero is reserved to indicate that
+ all rows should be retrieved and is equivalent to specifying the ALL keyword.
+ If the RELATIVE keyword has been used, the
Postgres
+ assumes that the user intended
SQL92 behavior
+ and returns this error message.
+
+
+
+
+
+
+
+
+
+
+
+ 1998-04-15
+
+
+ Description
+
FETCH allows a user to retrieve rows using a cursor.
The number of rows retrieved is specified by
- # >.
+ # >.
If the number of rows remaining in the cursor is less
- than <REPLACEABLE CLASS="PARAMETER">#>,
- then only those available are fetched.
+ than <replaceable class="PARAMETER">#>,
+ then only those available are fetched.
Substituting the keyword ALL in place of a number will
cause all remaining rows in the cursor to be retrieved.
Instances may be fetched in both FORWARD and BACKWARD
directions. The default direction is FORWARD.
-
-Negative numbers are now allowed to be specified for the
-row count. A negative number is equivalent to reversing
-the sense of the FORWARD and BACKWARD keywords. For example,
-FORWARD -1 is the same as BACKWARD 1 .
-
-
-
-Note that the FORWARD and BACKWARD keywords are
-The
SQL92 syntax is also supported, specified
-in the second form of the command. See below for details
-on compatibility issues.
-
+
+ Negative numbers are now allowed to be specified for the
+ row count. A negative number is equivalent to reversing
+ the sense of the FORWARD and BACKWARD keywords. For example,
+ FORWARD -1 is the same as BACKWARD 1 .
+
+
+
+ Note that the FORWARD and BACKWARD keywords are
+
The
SQL92 syntax is also supported, specified
+ in the second form of the command. See below for details
+ on compatibility issues.
+
Once all rows are fetched, every other fetch access returns
no rows.
-
+
Updating data in a cursor is not supported by
because mapping cursor updates back to base tables is
-not generally possible, as is also the case with VIEW updates.
- Consequently,
+ not generally possible, as is also the case with VIEW updates.
+ Consequently,
users must issue explicit UPDATE commands to replace data.
Cursors may only be used inside of transactions because
the data that they store spans multiple user queries.
-
-
-
-
-1998-04-15
-
-
-Notes
-
- Refer to MOVE statements to change cursor position.
- Refer to DECLARE statements to declare a cursor.
- Refer to BEGIN WORK, COMMIT WORK, ROLLBACK WORK statements
- for further information about transactions.
-
-
-
-
-
-
-Usage
-
+
+
+
+
+ 1998-04-15
+
+
+ Notes
+
+ Use MOVE to change cursor position.
+ DECLARE will define a cursor.
+ Refer to BEGIN , COMMIT , and
+ ROLLBACK
+ for further information about transactions.
+
+
+
+
+
+
+ Usage
+
--set up and use a cursor:
--
BEGIN WORK;
--
CLOSE liahona;
COMMIT WORK;
-
-
-
-
-
-
-Compatibility
-
-The non-embedded use of cursors is a
Postgres
-extension. The syntax and usage of cursors is being compared
-against the embedded form of cursors defined in
SQL92 .
-
-
-
-
-1998-09-01
-
-
-SQL92
-
-
SQL92 allows absolute positioning of the cursor for
-FETCH, and allows placing the results into explicit variables.
-
-
-FETCH ABSOLUTE #
- FROM cursor
- INTO :variable [, ...]
-
-
-
-
-
-ABSOLUTE
-
-
-The cursor should be positioned to the specified absolute
-row number. All row numbers in
Postgres
-are relative numbers so this capability is not supported.
-
-
-
-
-
-:variable
-
-
-Target host variable(s).
-
-
-
-
-
-
-
-
-
-
-
-
-
- GRANT
-
- SQL - Language Statements
-
-
-
- GRANT
-
-
- Grants access privilege to a user, a group or all users
-
-
-
-
- 1998-09-23
-
-
- GRANT privilege [, ...]
- ON object [, ...]
- TO { PUBLIC | GROUP group | username }
-
+
+
+
+ GRANT
+
+ SQL - Language Statements
+
+
+
+ GRANT
+
+
+ Grants access privilege to a user, a group or all users
+
+
+
+
+ 1998-09-23
+
+
+GRANT privilege [, ...] ON object [, ...]
+ TO { PUBLIC | GROUP group | username }
+
-
-
- 1998-09-23
-
-
- Inputs
-
-
-
-
-
- privilege
-
-
- The possible privileges are:
-
-
-
-
-
- SELECT
-
-
- Access all of the columns of a specific
- table/view.
-
-
-
-
-
-
- INSERT
-
-
- Insert data into all columns of a
- specific table.
-
-
-
-
-
-
- UPDATE
-
-
- Update all columns of a specific
- table.
-
-
-
-
-
-
- DELETE
-
-
- Delete rows from a specific table.
-
-
-
-
-
-
- RULE
-
-
- Define rules on the table/view
- (See CREATE RULE statement).
-
-
-
-
-
-
- ALL
-
-
- Grant all privileges.
-
-
-
-
-
-
- object
-
-
- The name of an object to which to grant access.
- The possible objects are:
-
-
-
-
- table
-
-
-
-
- view
-
-
-
-
- sequence
-
-
-
-
- index
-
-
-
-
-
-
-
-
-
- PUBLIC
-
-
- A short form representing all users.
-
-
-
-
-
- GROUP group
-
-
- A group to whom to grant privileges.
- In the current release, the group must be created explicitly as described below.
-
-
-
-
-
-
- username
-
-
- The name of a user to whom grant privileges. PUBLIC is a short form
- representing all users.
-
-
-
-
-
-
-
-
-
- 1998-09-23
-
-
- Outputs
-
-
-
-
-
- CHANGE
-
-
- Message returned if successful.
-
-
-
-
-
-
- ERROR: ChangeAcl: class "object "
- not found
-
-
- Message returned if the specified object is not available or
- if it is impossible
- to give privileges to the specified group or users.
-
-
-
-
-
-
-
-
-
-
- 1998-09-23
-
-
- Description
-
- GRANT allows the creator of an object to give specific permissions to
- all users (PUBLIC) or to a certain user or group.
- Users other than the creator don't have any access permission
- unless the creator GRANTs permissions, after the object
- is created.
-
-
- Once a user has a privilege on an object, he is enabled to exercise
- that privilege.
- There is no need to GRANT privileges to the creator of
- an object, the creator automatically holds ALL privileges, and can
- also drop the object.
-
-
-
-
- 1998-09-23
-
-
- Notes
-
- Use the psql \z command
- for further information about permissions
- on existing objects:
+
+
+ 1998-09-23
+
+
+ Inputs
+
+
+
+
+ privilege
+
+ The possible privileges are:
+
+
+
+ SELECT
+
+ Access all of the columns of a specific
+ table/view.
+
+
+
+
+
+ INSERT
+
+ Insert data into all columns of a
+ specific table.
+
+
+
+
+
+ UPDATE
+
+ Update all columns of a specific
+ table.
+
+
+
+
+
+ DELETE
+
+ Delete rows from a specific table.
+
+
+
+
+
+ RULE
+
+ Define rules on the table/view
+ (See CREATE RULE statement).
+
+
+
+
+
+ ALL
+
+ Grant all privileges.
+
+
+
+
+
+
+
+
+
+ object
+
+ The name of an object to which to grant access.
+ The possible objects are:
+
+
+
+ table
+
+
+
+
+ view
+
+
+
+
+ sequence
+
+
+
+
+ index
+
+
+
+
+
+
+
+
+ PUBLIC
+
+ A short form representing all users.
+
+
+
+
+
+ GROUP group
+
+ A group to whom to grant privileges.
+ In the current release, the group must be created explicitly as described below.
+
+
+
+
+
+
+ username
+
+
+ The name of a user to whom grant privileges. PUBLIC is a short form
+ representing all users.
+
+
+
+
+
+
+
+
+
+ 1998-09-23
+
+
+ Outputs
+
+
+
+
+
+CHANGE
+
+
+ Message returned if successful.
+
+
+
+
+
+
+ERROR: ChangeAcl: class "object " not found
+
+
+ Message returned if the specified object is not available or
+ if it is impossible
+ to give privileges to the specified group or users.
+
+
+
+
+
+
+
+
+
+
+ 1998-09-23
+
+
+ Description
+
+ GRANT allows the creator of an object to give specific permissions to
+ all users (PUBLIC) or to a certain user or group.
+ Users other than the creator don't have any access permission
+ unless the creator GRANTs permissions, after the object
+ is created.
+
+
+ Once a user has a privilege on an object, he is enabled to exercise
+ that privilege.
+ There is no need to GRANT privileges to the creator of
+ an object, the creator automatically holds ALL privileges, and can
+ also drop the object.
+
+
+
+
+ 1998-09-23
+
+
+ Notes
+
+
+ Currently, to grant privileges in
Postgres
+ to only few columns, you must
+ create a view having desired columns and then grant privileges
+ to that view.
+
+
+ Use psql \z
+ for further information about permissions
+ on existing objects:
Database = lusitania
+------------------+---------------------------------------------+
| Relation | Grant/Revoke Permissions |
a -- INSERT
R -- RULE
arwR -- ALL
-
+
-
- Currently, to create a GROUP you have to insert
- data manually into table pg_group as:
- INSERT INTO pg_group VALUES ('todos');
- CREATE USER miriam IN GROUP todos;
-
- Refer to REVOKE statements to revoke access privileges.
-
-
-
-
-
-
-
-
- Usage
-
- -- grant insert privilege to all users on table films:
- --
- GRANT INSERT ON films TO PUBLIC;
-
-
+
+ Currently, to create a GROUP you have to insert
+ data manually into table pg_group as:
- -- grant all privileges to user manuel on view kinds:
- --
- GRANT ALL ON kinds TO manuel;
-
-
-
-
-
-
- Compatibility
-
-
+INSERT INTO pg_group VALUES ('todos');
+CREATE USER miriam IN GROUP todos;
+
+
+
+
+
+ Refer to REVOKE statements to revoke access privileges.
+
+
+
+
+
+
+ Usage
+
+ Grant insert privilege to all users on table films:
+
+GRANT INSERT ON films TO PUBLIC;
+
+
+
+ Grant all privileges to user manuel on view kinds:
+
+GRANT ALL ON kinds TO manuel;
+
+
+
+
+
+
+ Compatibility
+
+
-
-
- 1998-09-23
-
-
- SQL92
-
- The
SQL92 syntax for GRANT allows setting privileges
- for individual columns
- within a table, and allows setting a privilege to grant
- the same privileges to others.
-
-
- GRANT privilege [, ...]
- ON object [ ( column [, ...] ) ] [, ...]
- TO { PUBLIC | username [, ...] }
- [ WITH GRANT OPTION ]
-
-
- Fields are compatible with the those in the
Postgres
- implementation, with the following additions:
-
-
-
-
- privilege
- SELECT
-
-
-
SQL92 permits additional privileges to be specified:
-
-
-
-
-
-
- REFERENCES
-
-
- Allowed to reference some or all of the columns of a specific
- table/view in integrity constraints.
-
-
-
-
-
-
- USAGE
-
-
- Allowed to use a domain, character set, collation
- or translation.
- If an object specifies anything other than a table/view,
- privilege
- must specify only USAGE.
-
-
-
-
+
+
+ 1998-09-23
+
+
+ SQL92
+
+ The
SQL92 syntax for GRANT allows setting privileges
+ for individual columns
+ within a table, and allows setting a privilege to grant
+ the same privileges to others:
+
+
+GRANT privilege [, ...]
+ ON object [ ( column [, ...] ) ] [, ...]
+ TO { PUBLIC | username [, ...] } [ WITH GRANT OPTION ]
+
+
+
+ Fields are compatible with the those in the
Postgres
+ implementation, with the following additions:
+
+
+
+ privilege
+
+
SQL92 permits additional privileges to be specified:
+
+
+
+ SELECT
+
+
+
+
+
+
+ REFERENCES
+
+ Allowed to reference some or all of the columns of a specific
+ table/view in integrity constraints.
+
+
+
+
+
+ USAGE
+
+ Allowed to use a domain, character set, collation
+ or translation.
+ If an object specifies anything other than a table/view,
+ privilege
+ must specify only USAGE.
+
+
+
-
-
- Currently, to grant privileges in
Postgres
- to only few columns, you must
- create a view having desired columns and then grant privileges
- to that view.
-
-
-
+
+
+
+
+
+ object
+
+
-
-
- object
-
-
-
-
-
-
- object
-
-
-
SQL92 allows an additional non-functional keyword:
-
-
-
- [ TABLE ] table
-
-
-
-
-
-
-
-
- CHARACTER SET
-
-
- Allowed to use the specified character set.
-
-
-
-
-
-
- COLLATION
-
-
- Allowed to use the specified collation sequence.
-
-
-
-
-
-
- TRANSLATION
-
-
- Allowed to use the specified character set translation.
-
-
-
-
-
-
- DOMAIN
-
-
- Allowed to use the specified domain.
-
-
-
-
-
-
- WITH GRANT OPTION
-
-
- Allowed to grant the same privilege to others.
-
-
-
-
-
-
-
+
+ [ TABLE ] table
+
+
SQL92 allows the additional
+ non-functional keyword TABLE .
+
+
+
+
+
+ CHARACTER SET
+
+ Allowed to use the specified character set.
+
+
+
+
+
+ COLLATION
+
+ Allowed to use the specified collation sequence.
+
+
+
+
+
+ TRANSLATION
+
+ Allowed to use the specified character set translation.
+
+
+
+
+
+ DOMAIN
+
+ Allowed to use the specified domain.
+
+
+
+
+
+ WITH GRANT OPTION
+
+ Allowed to grant the same privilege to others.
+
+
+
-
-
-
-
-
-
-<REFENTRY ID ="APP-INITDB">
->
->
->
-Application >
->
->
->
->
->
-Create a new
Postgres database installation
->
-
->
->
-1998-10-02 >
->
->
+<refentry id ="APP-INITDB">
+ >
+ >
+ >
+ Application >
+ >
+ >
+ >
+ >
+ >
+
Create a new
Postgres database installation
+ >
+
+ >
+ >
+ 1998-10-02 >
+ >
+ >
initdb [ --pgdata=dbdir | -r dbdir ]
[ --pglib=libdir | -l libdir ]
[ --template=template | -t template ]
[ --username=name | -u name ]
[ --noclean | -n ] [ --debug | -d ]
->
+ >
-
-
- 1998-10-02
-
-
- Inputs
-
-
-
-
- --pglib=libdir
-
-
- -l libdir
-
-
- PGLIB
-
-
- Where are the files that make up
Postgres ?
- Apart from files that
- have to go in particular directories because of their function, the
- files that make up the
Postgres software
- were installed in a directory
- called the libdir directory.
- An example of a file that will be found
- needs is global1.bki.source ,
- which contains all the information that goes
- into the shared catalog tables.
-
-
-
-
-
-
- --pgdata=dbdir
-
-
- -r dbdir
-
-
- PGDATA
-
-
- Where in your Unix filesystem do you want the database data to go?
- The top level directory is called the PGDATA directory.
-
-
-
-
-
-
- --username=name
-
-
- -u name
-
-
- PGUSER
-
-
- Who will be the
Postgres superuser
- for this database system? The
-
Postgres superuser is a Unix user
- who owns all files that store the database
- system and also owns the postmaster and backend processes that access them.
- Or just let it default to you (the Unix user who runs
-
-
- Only the Unix superuser (root )
- can create a database system with an owner
- different from the
Postgres superuser.
-
-
-
-
-
-
- Other, less commonly used, parameters are also available:
-
-
-
-
- --template=template
-
-
- -t template
-
-
- Replace the template1
- database in an existing database system, and don't touch anything else.
- This is useful when you need to upgrade your template1
- from a newer release of
Postgres ,
- or when your template1
- database has become corrupted by some system problem. Normally the
- contents of template1
- remain constant throughout the life of the database system. You can't
- destroy anything by running
initdb
- with the
- --template
- option.
-
-
-
-
-
-
- --noclean
-
-
- -n
-
-
- By default, when
initdb
- determines that error prevent it from completely creating the database
- system, it removes any files it may have created before determining
- that it can't finish the job. That includes any core files left by
- the programs it invokes. This option inhibits any tidying-up and is
- thus useful for debugging.
-
-
-
-
-
-
- --debug
-
-
- -d
-
-
- Print debugging output from the bootstrap backend.
- The bootstrap backend is the program
initdb
- uses to create the catalog tables. This option generates a tremendous
- amount of output. It also turns off the final vacuuming step.
-
-
-
-
-
-
- Files are also input to
initdb :
-
-
-
-
-
-
- If appearing somewhere in the Unix command search path
- (defined by the PATH environment variable).
- This is a program that specifies defaults for some of the
- command options. See below.
-
-
-
-
-
-
- PGLIB /global1.bki.source
-
-
- Contents for the shared catalog tables in the new database system. This
- file is part of the
Postgres software.
-
-
-
-
-
-
- PGLIB /local1_template1.bki.source
-
-
- Contents for the template1 tables in the new database system. This
- file is part of the
Postgres software.
-
-
-
-
-
-
-
+
+
+ 1998-10-02
+
+
+ Inputs
+
-
-
- 1998-09-26
-
-
- Outputs
-
-
initdb will create files in the
PGDATA
- data area which are the system tables and framework for a complete
- installation.
-
-
-
+
+
+ --pglib=libdir
+ -l libdir
+ PGLIB
+
+ Where are the files that make up
Postgres ?
+ Apart from files that
+ have to go in particular directories because of their function, the
+ files that make up the
Postgres software
+ were installed in a directory
+ called the libdir directory.
+ An example of a file that will be found
+ needs is global1.bki.source ,
+ which contains all the information that goes
+ into the shared catalog tables.
+
+
+
-
-
- 1998-09-26
-
-
- Description
-
-
Postgres database system.
- A database system is a
- collection of databases that are all administered by the same Unix user
- and managed by a single postmaster.
-
- Creating a database system consists of creating the directories in which
- the database data will live, generating the shared catalog tables
- (tables that don't belong to any particular database), and
- creating the template1
- database. What is the template1
- database? When you create a database,
Postgres
- does it by copying
- everything from the template1
- database. It contains catalog tables filled in for things like the
- builtin types.
-
- creates the database, it completes the initialization by running
-
vacuum , which resets some optimization parameters.
-
- There are three ways to give parameters to
initdb .
-
- First, you can use
initdb command options.
- Second, you can set environment
- variables before invoking
initdb .
- Third, you can have a program called
postconfig
- in your Unix command search path.
+
+ --pgdata=dbdir
+ -r dbdir
+ PGDATA
+
+ Where in your Unix filesystem do you want the database data to go?
+ The top level directory is called the PGDATA directory.
+
+
+
+
+
+ --username=name
+ -u name
+ PGUSER
+
+ Who will be the
Postgres superuser
+ for this database system? The
+
Postgres superuser is a Unix user
+ who owns all files that store the database
+ system and also owns the postmaster and backend processes that access them.
+ Or just let it default to you (the Unix user who runs
+
+
+ Only the Unix superuser (root )
+ can create a database system with an owner
+ different from the
Postgres superuser.
+
+
+
+
+
+
+
+ Other, less commonly used, parameters are also available:
+
+
+
+ --template=template
+ -t template
+
+ Replace the template1
+ database in an existing database system, and don't touch anything else.
+ This is useful when you need to upgrade your template1
+ from a newer release of
Postgres ,
+ or when your template1
+ database has become corrupted by some system problem. Normally the
+ contents of template1
+ remain constant throughout the life of the database system. You can't
+ destroy anything by running
initdb
+ with the
+ --template
+ option.
+
+
+
+
+
+ --noclean
+ -n
+
+ By default, when
initdb
+ determines that error prevent it from completely creating the database
+ system, it removes any files it may have created before determining
+ that it can't finish the job. That includes any core files left by
+ the programs it invokes. This option inhibits any tidying-up and is
+ thus useful for debugging.
+
+
+
+
+
+ --debug
+ -d
+
+ Print debugging output from the bootstrap backend.
+ The bootstrap backend is the program
initdb
+ uses to create the catalog tables. This option generates a tremendous
+ amount of output. It also turns off the final vacuuming step.
+
+
+
+
+
+
+
+ Files are also input to
initdb :
+
+
+
+
+ If appearing somewhere in the Unix command search path
+ (defined by the PATH environment variable).
+ This is a program that specifies defaults for some of the
+ command options. See below.
+
+
+
+
+
+ PGLIB /global1.bki.source
+
+ Contents for the shared catalog tables in the new database system. This
+ file is part of the
Postgres software.
+
+
+
+
+
+ PGLIB /local1_template1.bki.source
+
+ Contents for the template1 tables in the new database system. This
+ file is part of the
Postgres software.
+
+
+
+
+
+
+
+
+
+
+ 1998-09-26
+
+
+ Outputs
+
+
initdb will create files in the
+ PGDATA
+ data area which are the system tables and framework for a complete
+ installation.
+
+
+
+
+
+
+ 1998-09-26
+
+
+ Description
+
+
Postgres database system.
+ A database system is a
+ collection of databases that are all administered by the same Unix user
+ and managed by a single postmaster.
+
+ Creating a database system consists of creating the directories in which
+ the database data will live, generating the shared catalog tables
+ (tables that don't belong to any particular database), and
+ creating the template1
+ database. What is the template1
+ database? When you create a database,
Postgres
+ does it by copying
+ everything from the template1
+ database. It contains catalog tables filled in for things like the
+ builtin types.
+
+ creates the database, it completes the initialization by running
+
vacuum , which resets some optimization parameters.
+
+ There are three ways to give parameters to
initdb .
+
+
+
+ You can use
initdb command options.
+
+
+
+ You can set environment
+ variables before invoking
initdb .
+
+
+
+
+ You can have a program called
postconfig
+ in your Unix command search path.
initdb invokes that program and that program then writes
initdb parameters to its standard output stream.
This third option is not a common thing to do, however.
-
- Command options always override parameters specified any other way.
- The values returned by
postconfig
- override any environment variables, but your
- program may base its output on the environment variables if you want
- their values to be used.
-
- The value that
postconfig
- outputs must have the format
- var1 =value1 var2 =value2 ...
-
-
- It can output nothing if it doesn't want to supply any parameters.
- The var values are equal to
- the corresponding environment variable
- names. For example,
- PGDATA=/tmp/postgres_test
-
- has the
- same effect as invoking
initdb
- with an environment variable called PGDATA whose value is
- /tmp/postgres_test .
-
-
-
+
+
+
+
+
+ Command options always override parameters specified any other way.
+ The values returned by
postconfig
+ override any environment variables, but your
+ program may base its output on the environment variables if you want
+ their values to be used.
+
+
+ The value that
postconfig
+ outputs must have the format
+
+var1 =value1 var2 =value2 ...
+
+
+ It can output nothing if it doesn't want to supply any parameters.
+ The var values are equal to
+ the corresponding environment variable
+ names. For example,
+PGDATA=/tmp/postgres_test
+
+ has the
+ same effect as invoking
initdb
+ with an environment variable called PGDATA whose value is
+ /tmp/postgres_test .
+
+
+
+
+
-<REFENTRY ID ="APP-INITLOCATION">
->
->
->
-Application >
->
->
->
->
->
-Create a secondary
Postgres database storage area
->
-
->
->
-1998-10-02 >
->
->
-initlocation [ --location=altdirble> | -D altdir ]
+<refentry id ="APP-INITLOCATION">
+ >
+ >
+ >
+ Application >
+ >
+ >
+ >
+ >
+ >
+
Create a secondary
Postgres database storage area
+ >
+
+ >
+ >
+ 1998-10-02 >
+ >
+ >
+initlocation [ --location=er">al ble> | -D altdir ]
[ --username=name | -u name ]
[ altdir ]
->
+ >
-
-
- 1998-10-02
-
-
- Inputs
-
-
-
-
-
- --location=altdir
-
-
- -D altdir
-
-
- altdir
-
-
- Where in your Unix filesystem do you want alternate databases to go?
- The top level directory is called the PGDATA directory, so you
- might want to point your first alternate location at PGDATA2 .
-
-
-
-
-
-
- --username=name
-
-
- -u name
-
-
- PGUSER
-
-
- Who will be the Unix filesystem owner of this database storage area?
- The
-
Postgres superuser is a Unix user
- who owns all files that store the database
- system and also owns the postmaster and backend processes that access them.
- Usually, this is the user who should run
initlocation
- and who will thus have ownership of the directories and files.
-
-
- Only the Unix superuser can create a database system with a
- different user as the
Postgres superuser.
- Specifying a user other than the
Postgres superuser
- may lead to database security and data integrity problems. Refer to the
-
PostgreSQL Administrator's Guide
- for more information.
-
-
-
-
-
-
-
-
-
-
-
- 1998-09-26
-
-
- Outputs
-
-
initlocation will create directories in
- the specified place.
-
-
-
-
- We are initializing the database area with username postgres (uid=500).
- This user will own all the files and must also own the server process.
- Creating Postgres database system directory altdir
- Creating Postgres database system directory altdir
-
-
- Successful completion.
-
-
-
-
-
-
- We are initializing the database area with username postgres (uid=500).
- This user will own all the files and must also own the server process.
- Creating Postgres database system directory /usr/local/src/testlocation
- mkdir: cannot make directory `altdir ': Permission denied
-
-
- You do not have filesystem permission to write to the specified directory area.
-
-
-
-
-
-
- Valid username not given. You must specify the username for
- the Postgres superuser for the database system you are
- initializing, either with the --username option or by default
- to the USER environment variable.
-
-
- The username which you have specified is not the
-
-
-
-
-
-
- Can't tell what username to use. You don't have the USER
- environment variable set to your username and didn't specify the
- --username option
-
-
- Specify the --username command line option.
-
-
-
-
-
-
-
-
+
+
+ 1998-10-02
+
+
+ Inputs
+
-
-
- 1998-09-26
-
-
- Description
-
- creates a new
Postgres secondary database storage area.
- A secondary storage area contains a required tree of directories with
- the correct file permissions on those directories.
-
- Creating a database storage area consists of creating the directories in which
- database data might live.
-
- There are two kinds of arguments for
initlocation .
- First, you can specify an environment variable (e.g. PGDATA2 ).
- This environment variable should be known to the backend for later use in
- CREATE DATABASE/WITH LOCATION
- or
- createdb -D altdir .
- However, the backend daemon must have this variable in it's
- environment for this to succeed.
-
- Second, you may be able to specify an explicit
- absolute path to the top directory of the storage area. However,this second
- option is possible only if explicitly enabled during the
-
Postgres installation. It is usually disabled
- to alleviate security and data integrity concerns.
-
-
-
Postgres will add
/base/
- to the specified path to create the storage area.
-
- The backend requires that any argument to WITH LOCATION which is
- in all uppercase and which has no path delimiters is an environment variable.
-
-
-
+
+
+ --location=altdir
+ -D altdir
+ altdir
+
+ Where in your Unix filesystem do you want alternate databases to go?
+ The top level directory is called the PGDATA directory, so you
+ might want to point your first alternate location at
+ PGDATA2 .
+
+
+
-
-
- 1998-09-26
-
-
- Usage
-
- To create a database in an alternate location, using an environment variable:
+
+ --username=name
+ -u name
+ PGUSER
+
+ Who will be the Unix filesystem owner of this database storage area?
+ The
+
Postgres superuser is a Unix user
+ who owns all files that store the database
+ system and also owns the postmaster and backend processes that access them.
+ Usually, this is the user who should run
initlocation
+ and who will thus have ownership of the directories and files.
+
+
+ Only the Unix superuser can create a database system with a
+ different user as the
Postgres superuser.
+ Specifying a user other than the
Postgres superuser
+ may lead to database security and data integrity problems. Refer to the
+
PostgreSQL Administrator's Guide
+ for more information.
+
+
+
+
+
+
+
- % setenv PGDATA2 /opt/postgres/data
-
- % initlocation PGDATA2
- % createdb -D PGDATA2
-
-
-
-
+
+
+ 1998-09-26
+
+
+ Outputs
+
+
initlocation will create directories in
+ the specified place.
+
+
+
+
+We are initializing the database area with username postgres (uid=500).
+This user will own all the files and must also own the server process.
+Creating Postgres database system directory altdir
+Creating Postgres database system directory altdir
+
+
+ Successful completion.
+
+
+
+
+
+
+We are initializing the database area with username postgres (uid=500).
+This user will own all the files and must also own the server process.
+Creating Postgres database system directory /usr/local/src/testlocation
+mkdir: cannot make directory `altdir ': Permission denied
+
+
+ You do not have filesystem permission to write to the specified directory area.
+
+
+
+
+
+
+Valid username not given. You must specify the username for
+the Postgres superuser for the database system you are
+initializing, either with the --username option or by default
+to the USER environment variable.
+
+
+ The username which you have specified is not the
+
+
+
+
+
+
+Can't tell what username to use. You don't have the USER
+environment variable set to your username and didn't specify the
+--username option
+
+
+ Specify the --username command line option.
+
+
+
+
+
+
+
+
+
+
+
+ 1998-09-26
+
+
+ Description
+
+ creates a new
Postgres secondary database storage area.
+ A secondary storage area contains a required tree of directories with
+ the correct file permissions on those directories.
+
+ Creating a database storage area consists of creating the directories in which
+ database data might live.
+
+ There are two kinds of arguments for
initlocation .
+
+ First, you can specify an environment variable (e.g. PGDATA2 ).
+ This environment variable should be known to the backend for later use in
+ CREATE DATABASE/WITH LOCATION
+ or
+ createdb -D altdir .
+ However, the backend daemon must have this variable in it's
+ environment for this to succeed.
+
+ Second, you may be able to specify an explicit
+ absolute path to the top directory of the storage area. However,this second
+ option is possible only if explicitly enabled during the
+
Postgres installation. It is usually disabled
+ to alleviate security and data integrity concerns.
+
+
+
Postgres will add
/base/
+ to the specified path to create the storage area.
+
+ The backend requires that any argument to WITH LOCATION which is
+ in all uppercase and which has no path delimiters is an environment variable.
+
+
+
+
+
+
+ 1998-09-26
+
+
+ Usage
+
+ To create a database in an alternate location, using an environment variable:
+
+% setenv PGDATA2 /opt/postgres/data
+% initlocation PGDATA2
+% createdb -D PGDATA2
+
+
+
+
+
+
-<REFENTRY ID ="SQL-INSERT">
->
->
-INSERT
->
-SQL - Language Statements >
->
->
->
-INSERT
->
->
-Inserts new rows into a table
->
+<refentry id ="SQL-INSERT">
+ >
+ >
+ INSERT
+ >
+ SQL - Language Statements >
+ >
+ >
+ >
+ INSERT
+ >
+ >
+ Inserts new rows into a table
+ >
- <REFSYNOPSISDIV >
- <REFSYNOPSISDIVINFO >
- <DATE>1998-09-23>
- REFSYNOPSISDIVINFO >
- <SYNOPSIS >
- INSERT INTO table [ ( column > [, ...] ) ]
- { VALUES ( expression [, ...] ) | SELECT query > }
- SYNOPSIS >
+ <refsynopsisdiv >
+ <refsynopsisdivinfo >
+ <date>1998-09-23>
+ refsynopsisdivinfo >
+ <synopsis >
+INSERT INTO table [ ( column > [, ...] ) ]
+ { VALUES ( expression [, ...] ) | SELECT query > }
+ synopsis >
- <REFSECT2 ID ="R2-SQL-INSERT-1">
- <REFSECT2INFO >
- <DATE>1998-09-23>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-SQL-INSERT-1">
+ <refsect2info >
+ <date>1998-09-23>
+ refsect2info >
+ <title >
Inputs
-
-
-
-
-
- table
-
-
- The name of an existing table.
-
-
-
-
-
- column
-
-
- The name of a column in table .
-
-
-
-
-
-
- expression
-
-
- A valid expression or value to assign to column .
-
-
-
-
-
-
- query
-
-
- A valid query. Refer to the SELECT statement for a further description
- of valid arguments.
-
-
-
-
-
-
-
-
-
-
- 1998-09-23
-
-
- Outputs
-
-
-
-
-
- INSERT oid 1
-
-
- Message returned if only one row was inserted.
- oid
- is the numeric
OID of the inserted row.
-
-
-
-
-
- INSERT 0 #
-
-
- Message returned if more than one rows were inserted.
- #
- is the number of rows inserted.
-
-
-
-
-
-
-
+
+
+
+
+ table
+
+ The name of an existing table.
+
+
+
+
+ column
+
+ The name of a column in table .
+
+
+
+
+
+ expression
+
+ A valid expression or value to assign to
+ class="PARAMETER">column.
+
+
+
+
+
+ query
+
+ A valid query. Refer to the SELECT statement for a further description
+ of valid arguments.
+
+
+
+
+
+
-
-
- 1998-09-02
-
-
- Description
-
- INSERT allows one to insert new rows into a table. One can insert
- a single row at time or several rows as a result of a query.
- The columns in the target list may be listed in any order.
- In every column not present in the target list will be inserted
- the default value, if column has not a declared default value
- it will be assumed as NULL. If the expression for each column
- is not of the correct data type, automatic type coercion will be
- attempted.
-
- You must have insert privilege to a table in order to append
- to it, as well as select privilege on any table specified
- in a WHERE clause.
-
-
-
-
-
- Usage
-
- --Insert a single row into table films;
- --(in the second example the column date_prod is omitted
- --therefore will be stored in it a default value of NULL):
- --
- INSERT INTO films VALUES
- ('UA502','Bananas',105,'1971-07-13','Comedy',INTERVAL '82 minute');
-
- INSERT INTO films (code, title, did, date_prod, kind)
- VALUES ('T_601', 'Yojimbo', 106, DATE '1961-06-16', 'Drama');
-
-
- --Insert a single row into table distributors, note that
- --only column "name" is specified, to the non specified
- --column "did" will be assigned its default value:
- --
- INSERT INTO distributors (name) VALUES ('British Lion');
-
-
- --Insert several rows into table films from table tmp:
- --
- INSERT INTO films
- SELECT * FROM tmp;
-
-
- --Insert into arrays:
- --Create an empty 3x3 gameboard for noughts-and-crosses
- --(all of these queries create the same board attribute)
- --(Refer to the PostgreSQL User's Guide for further
- --information about arrays).
+
+
+ 1998-09-23
+
+
+ Outputs
+
+
+
+
+
+INSERT oid 1
+
+
+ Message returned if only one row was inserted.
+ oid
+ is the numeric
OID of the inserted row.
+
+
+
+
+
+INSERT 0 #
+
+
+ Message returned if more than one rows were inserted.
+ #
+ is the number of rows inserted.
+
+
+
+
+
+
+
+
+
+
+ 1998-09-02
+
+
+ Description
+
+ INSERT allows one to insert new rows into a table. One can insert
+ a single row at time or several rows as a result of a query.
+ The columns in the target list may be listed in any order.
+ In every column not present in the target list will be inserted
+ the default value, if column has not a declared default value
+ it will be assumed as NULL. If the expression for each column
+ is not of the correct data type, automatic type coercion will be
+ attempted.
+
+ You must have insert privilege to a table in order to append
+ to it, as well as select privilege on any table specified
+ in a WHERE clause.
+
+
+
+
+
+ Usage
+
+ Insert a single row into table films :
+
+INSERT INTO films VALUES
+ ('UA502','Bananas',105,'1971-07-13','Comedy',INTERVAL '82 minute');
+
+
+
+ In this second example the column date_prod is
+ omitted and therefore it will have the default value of NULL:
+
+INSERT INTO films (code, title, did, date_prod, kind)
+ VALUES ('T_601', 'Yojimbo', 106, DATE '1961-06-16', 'Drama');
+
+
+
+ Insert a single row into table distributors; note that
+ only column name is specified, so the omitted
+ column did will be assigned its default value:
+
+INSERT INTO distributors (name) VALUES ('British Lion');
+
+
+
+ Insert several rows into table films from table tmp :
+
+INSERT INTO films SELECT * FROM tmp;
+
+
+
+ Insert into arrays (refer to The PostgreSQL User's Guide for further
+ information about arrays):
- INSERT INTO tictactoe (game, board[1:3][1:3])
- VALUES (1,'{{"","",""},{},{"",""}}');
- INSERT INTO tictactoe (game, board[3][3])
- VALUES (2,'{}');
- INSERT INTO tictactoe (game, board)
- VALUES (3,'{{,,},{,,},{,,}}');
-
-
-
-
-
-
- Compatibility
-
-
+-- Create an empty 3x3 gameboard for noughts-and-crosses
+-- (all of these queries create the same board attribute)
+INSERT INTO tictactoe (game, board[1:3][1:3])
+ VALUES (1,'{{"","",""},{},{"",""}}');
+INSERT INTO tictactoe (game, board[3][3])
+ VALUES (2,'{}');
+INSERT INTO tictactoe (game, board)
+ VALUES (3,'{{,,},{,,},{,,}}');
+
+
+
+
+
+
+ Compatibility
+
+
-
-
- 1998-09-23
-
-
- SQL92
-
- The INSERT statement is fully compatible with
SQL92 .
- Possible limitations in features of the
- query
- clause are documented for the SELECT statement.
-
-
-
-
-
-
-
-
-
-LISTEN
-
-SQL - Language Statements
-
-
-
+
+
+
+ LISTEN
+
+ SQL - Language Statements
+
+
+
+ LISTEN
+
+
+ Listen for a response on a notify condition
+
+
+
+
+ 1998-10-07
+
+
+LISTEN name
+
+
+
+
+ 1998-10-07
+
+
+ Inputs
+
+
+
+
+ name
+
+ Name of notify condition.
+
+
+
+
+
+
+
+
+
+ 1998-09-24
+
+
+ Outputs
+
+
+
+
+
LISTEN
-
-
-Listen for notification on a notify condition
-
-
-
-
-1998-10-07
-
-
-LISTEN notifyname
-
+
+
+ Message returned upon successful completion of registration.
+
+
+
+
+
+NOTICE Async_Listen: We are already listening on name
+
+
+ If this backend is already registered for that notify condition.
+
+
+
+
+
+
+
+
+
+
+ 1998-10-07
+
+
+ Description
+
+
LISTEN registers the current
Postgres backend as a
+ listener on the notify condition
+ name .
+
+ Whenever the command
+ NOTIFY name
+ is invoked, either by this backend or another one connected to
+ the same database, all the backends currently listening on that notify
+ condition are notified, and each will in turn notify its connected
+ frontend application. See the discussion of NOTIFY
+ for more information.
+
+ A backend can be unregistered for a given notify condition with the
+ UNLISTEN command. Also, a backend's listen registrations
+ are automatically cleared when the backend process exits.
+
+ The method a frontend application must use to detect notify events depends on
+ which
Postgres application programming interface it
+ uses. With the basic libpq library, the application issues
+ LISTEN as an ordinary SQL command, and then must
+ periodically call the routine PQnotifies to find out
+ whether any notify events have been received. Other interfaces such as
+ libpgtcl provide higher-level methods for handling notify events; indeed,
+ with libpgtcl the application programmer should not even issue
+ LISTEN or UNLISTEN directly. See the
+ documentation for the library you are using for more details.
+
+ The reference page for NOTIFY contains a more extensive
+ discussion of the use of LISTEN and
+ NOTIFY .
+
+
+
+
+ 1998-10-07
+
+
+ Notes
+
+ name
+ can be any string valid as a name;
+ it need not correspond to the name of any actual table. If
+ notifyname
+ is enclosed in double-quotes, it need not even be a syntactically
+ valid name, but can be any string up to 31 characters long.
+
+ In some previous releases of
+ name
+ had to be enclosed in double-quotes when it did not correspond to any existing
+ table name, even if syntactically valid as a name. That is no longer required.
+
+
+
+
+
+
+ Usage
+
+ Configure and execute a listen/notify sequence from
psql :
+LISTEN virtual;
+NOTIFY virtual;
+
+ASYNC NOTIFY of 'virtual' from backend pid '11239' received
+
+
+
+
+
+
+ Compatibility
+
+
+
+
+ 1998-09-01
+
+
+ SQL92
+
+ There is no
LISTEN in
SQL92 .
+
+
+
+
-
-
- 1998-10-07
-
-
- Inputs
-
-
-
-
-
- notifyname
-
-
- Name of notify condition.
-
-
-
-
-
-
-
-
-
- 1998-09-24
-
-
- Outputs
-
-
-
-
-
- LISTEN
-
-
- Message returned upon successful completion of registration.
-
-
-
-
-
- NOTICE Async_Listen: We are already listening on notifyname
-
-
- If this backend is already registered for that notify condition.
-
-
-
-
-
-
-
-
-
-
- 1998-10-07
-
-
- Description
-
- LISTEN registers the current
Postgres backend as a
- listener on the notify condition
- notifyname .
-
- Whenever the command
- NOTIFY notifyname
- is invoked, either by this backend or another one connected to
- the same database, all the backends currently listening on that notify
- condition are notified, and each will in turn notify its connected
- frontend application. See the discussion of NOTIFY
- for more information.
-
- A backend can be deregistered for a given notify condition with the
- UNLISTEN command. Also, a backend's listen registrations
- are automatically cleared when the backend process exits.
-
- The method a frontend application must use to detect notify events depends on
- which
Postgres application programming interface it
- uses. With the basic libpq library, the application issues
- LISTEN as an ordinary SQL command, and then must
- periodically call the routine PQnotifies to find out
- whether any notify events have been received. Other interfaces such as
- libpgtcl provide higher-level methods for handling notify events; indeed,
- with libpgtcl the application programmer should not even issue
- LISTEN or UNLISTEN directly. See the
- documentation for the library you are using for more details.
-
- The reference page for NOTIFY contains a more extensive
- discussion of the use of LISTEN and
- NOTIFY .
-
-
-
-
- 1998-10-07
-
-
- Notes
-
- notifyname
- can be any string valid as a name;
- it need not correspond to the name of any actual table. If
- notifyname
- is enclosed in double-quotes, it need not even be a syntactically
- valid name, but can be any string up to 31 characters long.
-
- In some previous releases of
- notifyname
- had to be enclosed in double-quotes when it did not correspond to any existing
- table name, even if syntactically valid as a name. That is no longer required.
-
-
-
-
-
-
- Usage
-
- -- Configure and execute a listen/notify sequence from psql
- postgres=> listen virtual;
- LISTEN
- postgres=> notify virtual;
- NOTIFY
- ASYNC NOTIFY of 'virtual' from backend pid '11239' received
-
-
-
-
-
-
- Compatibility
-
-
-
-
- 1998-09-01
-
-
- SQL92
-
- There is no
LISTEN in
SQL92 .
-
-
-
-
+
-
-
-
- LOAD
-
- SQL - Language Statements
-
-
-
- LOAD
-
-
- Dynamically loads an object file
-
-
-
-
- 1998-09-24
-
-
-
-
- LOAD 'filename '
-
+
+
+
+ LOAD
+
+ SQL - Language Statements
+
+
+
+ LOAD
+
+
+ Dynamically loads an object file
+
+
+
+
+ 1998-09-24
+
+
+LOAD 'filename '
+
-
-
- 1998-09-01
-
-
- Inputs
-
-
-
-
-
- filename
-
-
- Object file for dynamic loading.
-
-
-
-
+
+
+ 1998-09-01
+
+
+ Inputs
+
+
+
+ filename
+
+ Object file for dynamic loading.
+
+
+
+
+
+
-
+
+
+ 1998-09-24
+
+
+ Outputs
+
-
-
- 1998-09-24
-
-
- Outputs
-
-
-
-
-
- LOAD
-
-
- Message returned on successful completion.
-
-
-
-
-
- ERROR: LOAD: could not open file 'filename '
-
-
- Message returned if the specified file is not found. The file must be visible
-
to the Postgres backend ,
- with the appropriate full path name specified, to avoid this message.
-
-
-
-
-
-
-
-
-
-
- 1998-09-24
-
-
- Description
-
- Loads an object (or ".o") file into the
-
Postgres backend address space. Once a
- file is loaded, all functions in that file can be accessed. This
- function is used in support of user-defined types and functions.
-
- If a file is not loaded using
- LOAD ,
- the file will be loaded automatically the first time the
- function is called by
Postgres .
- LOAD
- can also be used to reload an object file if it has been edited and
- recompiled. Only objects created from C language files are supported
- at this time.
-
-
-
- 1998-09-24
-
-
- Notes
-
- Functions in loaded object files should not call functions in other
- object files loaded through the
- LOAD
- command. For example, all functions in file A should
- call each other, functions in the standard or math libraries, or in
- Postgres itself. They should not call functions defined in a different
- loaded file B .
- This is because if B is reloaded, the Postgres loader is
- not able to relocate the calls from the functions in A into
- the new address space of B .
- If B is not reloaded, however, there will
- not be a problem.
-
- Object files must be compiled to contain position independent code.
- For example,
- on DECstations you must use
- with the -G 0 option when compiling object files to be
- loaded.
-
- Note that if you are porting
Postgres
- to a new platform, LOAD
- will have to work in order to support ADTs.
-
-
-
+
+
+
+LOAD
+
+
+ Message returned on successful completion.
+
+
+
+
+
+ERROR: LOAD: could not open file 'filename '
+
+
+ Message returned if the specified file is not found. The file must be visible
+
to the Postgres backend ,
+ with the appropriate full path name specified, to avoid this message.
+
+
+
+
+
+
+
-
-
- Usage
-
- --Load the file /usr/postgres/demo/circle.o
- --
- LOAD '/usr/postgres/demo/circle.o'
-
-
-
-
-
-
- Compatibility
-
-
-
-
-
- 1998-09-24
-
-
- SQL92
-
- There is no
LOAD in
SQL92 .
-
-
-
-
+
+
+ 1998-09-24
+
+
+ Description
+
+ Loads an object (or ".o") file into the
+
Postgres backend address space. Once a
+ file is loaded, all functions in that file can be accessed. This
+ function is used in support of user-defined types and functions.
+
+ If a file is not loaded using
+ LOAD ,
+ the file will be loaded automatically the first time the
+ function is called by
Postgres .
+ LOAD
+ can also be used to reload an object file if it has been edited and
+ recompiled. Only objects created from C language files are supported
+ at this time.
+
+
+
+ 1998-09-24
+
+
+ Notes
+
+ Functions in loaded object files should not call functions in other
+ object files loaded through the
+ LOAD
+ command. For example, all functions in file A should
+ call each other, functions in the standard or math libraries, or in
+ Postgres itself. They should not call functions defined in a different
+ loaded file B .
+ This is because if B is reloaded, the Postgres loader is
+ not able to relocate the calls from the functions in
+ A into
+ the new address space of B .
+ If B is not reloaded, however, there will
+ not be a problem.
+
+ Object files must be compiled to contain position independent code.
+ For example,
+ on DECstations you must use
+ with the -G 0 option when compiling object files to be
+ loaded.
+
+ Note that if you are porting
Postgres
+ to a new platform, LOAD
+ will have to work in order to support ADTs.
+
+
+
+
+
+
+ Usage
+
+ Load the file /usr/postgres/demo/circle.o :
+
+LOAD '/usr/postgres/demo/circle.o'
+
+
+
+
+
+
+ Compatibility
+
+
+
+
+
+ 1998-09-24
+
+
+ SQL92
+
+ There is no
LOAD in
SQL92 .
+
+
+
+
+
+
-
- table
-
+ table
The name of an existing table to lock.
-
- ACCESS SHARE MODE
-
+ ACCESS SHARE MODE
- This lock mode is acquired automatically over tables being queried.
-
Postgres releases automatically acquired
- ACCESS SHARE locks after the statement is done.
-
-
+ This lock mode is acquired automatically over tables being queried.
+
Postgres releases automatically acquired
+ ACCESS SHARE locks after the statement is done.
+
+
This is the least restrictive lock mode which conflicts only with
-
- ROW SHARE MODE
-
+ ROW SHARE MODE
-
- ROW EXCLUSIVE MODE
-
+ ROW EXCLUSIVE MODE
Automatically acquired by any UPDATE ,
DELETE , INSERT statement.
-
- SHARE MODE
-
+ SHARE MODE
-
- SHARE ROW EXCLUSIVE MODE
-
+ SHARE ROW EXCLUSIVE MODE
-
- EXCLUSIVE MODE
-
+ EXCLUSIVE MODE
-
- ACCESS EXCLUSIVE MODE
-
+ ACCESS EXCLUSIVE MODE
-
-
- ERROR table : Table does not exist.
-
+
+LOCK TABLE
+
+
+ The lock was successfully applied.
+
+
+
+
+
+
+ERROR table : Table does not exist.
+
Message returned if table
+ Illustrate a SHARE lock on a primary key table when going to perform
+ inserts into a foreign key table:
+
- --
- -- SHARE lock primary key table when going to perform
- -- insert into foreign key table.
- --
- BEGIN WORK;
- LOCK TABLE films IN SHARE MODE;
- SELECT id FROM films
- WHERE name = 'Star Wars: Episode I - The Phantom Menace';
- --
- -- Do ROLLBACK if record was not returned
- --
- INSERT INTO films_user_comments VALUES
- (_id_, 'GREAT! I was waiting for it for so long!');
- COMMIT WORK;
-
+BEGIN WORK;
+LOCK TABLE films IN SHARE MODE;
+SELECT id FROM films
+ WHERE name = 'Star Wars: Episode I - The Phantom Menace';
+-- Do ROLLBACK if record was not returned
+INSERT INTO films_user_comments VALUES
+ (_id_, 'GREAT! I was waiting for it for so long!');
+COMMIT WORK;
+
- --
- -- SHARE ROW EXCLUSIVE lock primary key table when going to perform
- -- delete operation.
- --
- BEGIN WORK;
- LOCK TABLE films IN SHARE ROW EXCLUSIVE MODE;
- DELETE FROM films_user_comments WHERE id IN
- (SELECT id FROM films WHERE rating < 5);
- DELETE FROM films WHERE rating < 5;
- COMMIT WORK;
-
+ Take a SHARE ROW EXCLUSIVE lock on a primary key table when going to perform
+ a delete operation:
+
+BEGIN WORK;
+LOCK TABLE films IN SHARE ROW EXCLUSIVE MODE;
+DELETE FROM films_user_comments WHERE id IN
+ (SELECT id FROM films WHERE rating < 5);
+DELETE FROM films WHERE rating < 5;
+COMMIT WORK;
+
-
Compatibility
+
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
-sgml-local-catalogs:"/usr/lib/sgml/CATALOG "
+sgml-local-catalogs:"/usr/lib/sgml/catalog "
sgml-local-ecat-files:nil
End:
-->
-
-
-
-MOVE
-
-SQL - Language Statements
-
-
-
-MOVE
-
-
-Moves cursor position
-
-
-
-
-1998-09-24
-
-
-MOVE [ selector ] [ count ]
- { IN | FROM } cursor
-FETCH [ RELATIVE ] [ { [ # | ALL | NEXT | PRIOR ] } ] FROM ] cursor
-
-
+
+
+
+ MOVE
+
+ SQL - Language Statements
+
+
+
+ MOVE
+
+
+ Moves cursor position
+
+
+
+
+ 1998-09-24
+
+
+MOVE [ selector ] [ count ]
+ { IN | FROM } cursor
+ FETCH [ RELATIVE ] [ { [ # | ALL | NEXT | PRIOR ] } ] FROM ] cursor
+
+
+
+
+
+ 1998-09-24
+
+
+ Description
+
+ MOVE allows a user to move cursor position a specified
+ number of rows.
+ MOVE works like the FETCH command,
+ but only positions the cursor and does
+ not return rows.
+
+ Refer to the FETCH command for details on syntax and usage.
+
-
-
- 1998-09-24
-
-
- Description
-
- MOVE allows a user to move cursor position a specified
- number of rows.
- MOVE works like the FETCH command,
- but only positions the cursor and does
- not return rows.
-
- Refer to the FETCH command for details on syntax and usage.
-
+
+
+ 1998-09-24
+
+
+ Notes
+
+ language extension.
+
+ Refer to FETCH for a description
+ of valid arguments.
+ Refer to DECLARE to declare a cursor.
+ Refer to BEGIN WORK , COMMIT WORK ,
+ ROLLBACK WORK statements
+ for further information about transactions.
+
+
+
-
-
- 1998-09-24
-
-
- Notes
-
- language extension.
-
- Refer to FETCH for a description
- of valid arguments.
- Refer to DECLARE to declare a cursor.
- Refer to BEGIN WORK , COMMIT WORK ,
- ROLLBACK WORK statements
- for further information about transactions.
-
-
-
+
+
+ Usage
+
+ Set up and use a cursor:
-
-
- Usage
-
- --set up and use a cursor:
- --
- BEGIN WORK;
- DECLARE liahona CURSOR FOR SELECT * FROM films;
-
- --Skip first 5 rows:
- --
- MOVE FORWARD 5 IN liahona;
-
- MOVE
-
- --Fetch 6th row in the cursor liahona:
- --
- FETCH 1 IN liahona;
-
- FETCH
- code |title |did| date_prod|kind |len
- -----+------+---+----------+----------+------
- P_303|48 Hrs|103|1982-10-22|Action | 01:37
- (1 row)
-
- -- close the cursor liahona and commit work:
- --
- CLOSE liahona;
- COMMIT WORK;
-
-
-
+BEGIN WORK;
+DECLARE liahona CURSOR FOR SELECT * FROM films;
+--Skip first 5 rows:
+MOVE FORWARD 5 IN liahona;
+
+MOVE
+
+--Fetch 6th row in the cursor liahona:
+FETCH 1 IN liahona;
+
+FETCH
+
+ code |title |did| date_prod|kind |len
+ -----+------+---+----------+----------+------
+ P_303|48 Hrs|103|1982-10-22|Action | 01:37
+ (1 row)
+
+-- close the cursor liahona and commit work:
+CLOSE liahona;
+COMMIT WORK;
+
+
+
- ="R1-SQL-MOVE-3">
- >
- Compatibility
- >
- >
+ ="R1-SQL-MOVE-3">
+ >
+ Compatibility
+ >
+ >
-
-
- 1998-09-01
-
-
- SQL92
-
- There is no SQL92 MOVE statement.
- one to FETCH rows from an absolute cursor position,
- implicitly moving the cursor to the correct place.
-
-
-
-
+
+
+ 1998-09-01
+
+
+ SQL92
+
+ There is no SQL92 MOVE statement.
+ one to FETCH rows from an absolute cursor position,
+ implicitly moving the cursor to the correct place.
+
+
+
+
+
+
-
-
-
-NOTIFY
-
-SQL - Language Statements
-
-
-
+
+
+
+ NOTIFY
+
+ SQL - Language Statements
+
+
+
+ NOTIFY
+
+
+ Signals all frontends and backends listening on a notify condition
+
+
+
+
+ 1998-10-07
+
+
+NOTIFY name
+
+
+
+
+ 1998-10-07
+
+
+ Inputs
+
+
+
+
+ notifyname
+
+ Notify condition to be signaled.
+
+
+
+
+
+
+
+
+
+ 1998-10-07
+
+
+ Outputs
+
+
+
+
+
NOTIFY
-
-
-Signals all frontends and backends listening on a notify condition
-
-
-
-
-1998-10-07
-
-
-
-
-NOTIFY notifyname
-
+
+
+ Acknowledgement that notify command has executed.
+
+
+
+
+ Notify events
+
+ Events are delivered to listening frontends; whether and how each frontend
+ application reacts depends on its programming.
+
+
+
+
+
+
+
+
+
+
+ 1998-10-07
+
+
+ Description
+
+ The NOTIFY command sends a notify event to each
+ frontend application that has previously executed
+ LISTEN notifyname
+ for the specified notify condition in the current database.
+
+ The information passed to the frontend for a notify event includes the notify
+ condition name and the notifying backend process's PID. It is up to the
+ database designer to define the condition names that will be used in a given
+ database and what each one means.
+
+ Commonly, the notify condition name is the same as the name of some table in
+ the database, and the notify event essentially means "I changed this table,
+ take a look at it to see what's new". But no such association is enforced by
+ the NOTIFY and LISTEN commands. For
+ example, a database designer could use several different condition names
+ to signal different sorts of changes to a single table.
+
+ NOTIFY provides a simple form of signal or
+ IPC (interprocess communication) mechanism for a collection of processes
+ accessing the same
Postgres database.
+ Higher-level mechanisms can be built by using tables in the database to
+ pass additional data (beyond a mere condition name) from notifier to
+ listener(s).
+
+ When NOTIFY is used to signal the occurrence of changes
+ to a particular table, a useful programming technique is to put the
+ NOTIFY in a rule that is triggered by table updates.
+ In this way, notification happens automatically when the table is changed,
+ and the application programmer can't accidentally forget to do it.
+
+ NOTIFY interacts with SQL transactions in some important
+ ways. Firstly, if a NOTIFY is executed inside a
+ transaction, the notify events are not delivered until and unless the
+ transaction is committed. This is appropriate, since if the transaction
+ is aborted we would like all the commands within it to have had no
+ effect, including NOTIFY . But it can be disconcerting if one
+ is expecting the notify events to be delivered immediately. Secondly, if
+ a listening backend receives a notify signal while it is within a transaction,
+ the notify event will not be delivered to its connected frontend until just
+ after the transaction is completed (either committed or aborted). Again, the
+ reasoning is that if a notify were delivered within a transaction that was
+ later aborted, one would want the notification to be undone somehow --- but
+ the backend cannot "take back" a notify once it has sent it to the frontend.
+ So notify events are only delivered between transactions. The upshot of this
+ is that applications using NOTIFY for real-time signaling
+ should try to keep their transactions short.
+
+ NOTIFY behaves like Unix signals in one important
+ respect: if the same condition name is signaled multiple times in quick
+ succession, recipients may get only one notify event for several executions
+ of NOTIFY . So it is a bad idea to depend on the number
+ of notifies received. Instead, use NOTIFY to wake up
+ applications that need to pay attention to something, and use a database
+ object (such as a sequence) to keep track of what happened or how many times
+ it happened.
+
+ It is common for a frontend that sends NOTIFY to be
+ listening on the same notify name itself. In that case it will get back a
+ notify event, just like all the other listening frontends. Depending on the
+ application logic, this could result in useless work --- for example,
+ re-reading a database table to find the same updates that that frontend just
+ wrote out. In
Postgres 6.4 and later, it is
+ possible to avoid such extra work by noticing whether the notifying backend
+ process's PID (supplied in the notify event message) is the same as one's own
+ backend's PID (available from libpq). When they are the same, the notify
+ event is one's own work bouncing back, and can be ignored. (Despite what was
+ said in the preceding paragraph, this is a safe technique.
+
Postgres keeps self-notifies separate from notifies
+ arriving from other backends, so you cannot miss an outside notify by ignoring
+ your own notifies.)
+
+
+
+
+ 1998-10-07
+
+
+ Notes
+
+ name
+ can be any string valid as a name;
+ it need not correspond to the name of any actual table. If
+ name
+ is enclosed in double-quotes, it need not even be a syntactically
+ valid name, but can be any string up to 31 characters long.
+
+ In some previous releases of
+ name
+ had to be enclosed in double-quotes when it did not correspond to any existing
+ table name, even if syntactically valid as a name. That is no longer required.
+
+ In
Postgres releases prior to 6.4, the backend
+ PID delivered in a notify message was always the PID of the frontend's own
+ backend. So it was not possible to distinguish one's own notifies from other
+ clients' notifies in those earlier releases.
+
+
+
-
-
- 1998-10-07
-
-
- Inputs
-
+
+
+ Usage
+
+ Configure and execute a listen/notify sequence from
-
-
-
- notifyname
-
-
- Notify condition to be signaled.
-
-
-
-
-
-
+LISTEN virtual;
+NOTIFY virtual;
+ASYNC NOTIFY of 'virtual' from backend pid '11239' received
+
+
+
-
-
- 1998-10-07
-
-
- Outputs
-
-
-
-
-
- NOTIFY
-
-
- Acknowledgement that notify command has executed.
-
-
-
-
-
- Notify events
-
-
- Events are delivered to listening frontends; whether and how each frontend
- application reacts depends on its programming.
-
-
-
-
-
-
-
-
-
-
- 1998-10-07
-
-
- Description
-
- The NOTIFY command sends a notify event to each
- frontend application that has previously executed
- LISTEN notifyname
- for the specified notify condition in the current database.
-
- The information passed to the frontend for a notify event includes the notify
- condition name and the notifying backend process's PID. It is up to the
- database designer to define the condition names that will be used in a given
- database and what each one means.
-
- Commonly, the notify condition name is the same as the name of some table in
- the database, and the notify event essentially means "I changed this table,
- take a look at it to see what's new". But no such association is enforced by
- the NOTIFY and LISTEN commands. For
- example, a database designer could use several different condition names
- to signal different sorts of changes to a single table.
-
- NOTIFY provides a simple form of signal or
- IPC (interprocess communication) mechanism for a collection of processes
- accessing the same
Postgres database.
- Higher-level mechanisms can be built by using tables in the database to
- pass additional data (beyond a mere condition name) from notifier to
- listener(s).
-
- When NOTIFY is used to signal the occurrence of changes
- to a particular table, a useful programming technique is to put the
- NOTIFY in a rule that is triggered by table updates.
- In this way, notification happens automatically when the table is changed,
- and the application programmer can't accidentally forget to do it.
-
- NOTIFY interacts with SQL transactions in some important
- ways. Firstly, if a NOTIFY is executed inside a
- transaction, the notify events are not delivered until and unless the
- transaction is committed. This is appropriate, since if the transaction
- is aborted we would like all the commands within it to have had no effect
- --- including NOTIFY . But it can be disconcerting if one
- is expecting the notify events to be delivered immediately. Secondly, if
- a listening backend receives a notify signal while it is within a transaction,
- the notify event will not be delivered to its connected frontend until just
- after the transaction is completed (either committed or aborted). Again, the
- reasoning is that if a notify were delivered within a transaction that was
- later aborted, one would want the notification to be undone somehow --- but
- the backend cannot "take back" a notify once it has sent it to the frontend.
- So notify events are only delivered between transactions. The upshot of this
- is that applications using NOTIFY for real-time signaling
- should try to keep their transactions short.
-
- NOTIFY behaves like Unix signals in one important
- respect: if the same condition name is signaled multiple times in quick
- succession, recipients may get only one notify event for several executions
- of NOTIFY . So it is a bad idea to depend on the number
- of notifies received. Instead, use NOTIFY to wake up
- applications that need to pay attention to something, and use a database
- object (such as a sequence) to keep track of what happened or how many times
- it happened.
-
- It is common for a frontend that sends NOTIFY to be
- listening on the same notify name itself. In that case it will get back a
- notify event, just like all the other listening frontends. Depending on the
- application logic, this could result in useless work --- for example,
- re-reading a database table to find the same updates that that frontend just
- wrote out. In
Postgres 6.4 and later, it is
- possible to avoid such extra work by noticing whether the notifying backend
- process's PID (supplied in the notify event message) is the same as one's own
- backend's PID (available from libpq). When they are the same, the notify
- event is one's own work bouncing back, and can be ignored. (Despite what was
- said in the preceding paragraph, this is a safe technique.
-
Postgres keeps self-notifies separate from notifies
- arriving from other backends, so you cannot miss an outside notify by ignoring
- your own notifies.)
-
-
-
-
- 1998-10-07
-
-
- Notes
-
- notifyname
- can be any string valid as a name;
- it need not correspond to the name of any actual table. If
- notifyname
- is enclosed in double-quotes, it need not even be a syntactically
- valid name, but can be any string up to 31 characters long.
-
- In some previous releases of
- notifyname
- had to be enclosed in double-quotes when it did not correspond to any existing
- table name, even if syntactically valid as a name. That is no longer required.
-
- In
Postgres releases prior to 6.4, the backend
- PID delivered in a notify message was always the PID of the frontend's own
- backend. So it was not possible to distinguish one's own notifies from other
- clients' notifies in those earlier releases.
-
-
-
+
+
+ Compatibility
+
+
-
-
- Usage
-
- -- Configure and execute a listen/notify sequence from psql
- postgres=> listen virtual;
- LISTEN
- postgres=> notify virtual;
- NOTIFY
- ASYNC NOTIFY of 'virtual' from backend pid '11239' received
-
-
-
+
+
+ 1998-09-24
+
+
+ SQL92
+
+ There is no NOTIFY statement in
+
+
+
+
-
-
- Compatibility
-
-
-
-
- 1998-09-24
-
-
- SQL92
-
- There is no
NOTIFY statement in
SQL92 .
-
-
-
-
+
-<REFENTRY ID ="APP-PG-DUMP">
->
- id="pg-dump">
->
-Application >
->
->
->
->
->
-Extract a
Postgres database into a script file
->
-
->
->
-1998-11-05 >
->
->
+<refentry id ="APP-PG-DUMP">
+ >
+ id="pg-dump">
+ >
+ Application >
+ >
+ >
+ >
+ >
+ >
+
Extract a
Postgres database into a script file
+ >
+
+ >
+ >
+ 1998-11-05 >
+ >
+ >
pg_dump [ dbname ]
pg_dump [ -h host ] [ -p port ]
- [ -t table ]
- [ -f outputfile ]
+ [ -t table ] [ -f outputfile ]
[ -a ] [ -c ] [ -d ] [ -D ] [ -n ] [ -N ]
[ -o ] [ -s ] [ -u ] [ -v ] [ -x ]
[ dbname ]
-
-
-
-
- 1998-11-05
-
-
- Inputs
-
-
pg_dump accepts the following command line arguments:
-
-
-
-
- dbname
-
-
- Specifies the name of the database to be extracted.
- dbname
- defaults to the value of the
- USER
- environment variable.
-
-
-
-
-
-
- -a
-
-
- Dump out only the data, no schema (definitions).
-
-
-
-
-
-
- -c
-
-
- Clean(drop) schema prior to create.
-
-
-
-
-
-
- -d
-
-
- Dump data as proper insert strings.
-
-
-
-
-
-
- -D
-
-
- Dump data as inserts with attribute names
-
-
-
-
-
-
- -f filename
-
-
- Specifies the output file. Defaults to stdout .
-
-
-
-
-
-
- -n
-
-
- Suppress double quotes around identifiers unless absolutely necessary.
- This may cause trouble loading this dumped data if there are reserved words
- used for identifiers.
- This was the default behavior in pre-v6.4
pg_dump .
-
-
-
-
-
-
- -N
-
-
- Include double quotes around identifiers.
- This is the default.
-
-
-
-
-
-
- -o
-
-
- Dump object identifiers (
OID s) for every table.
-
-
-
-
-
-
- -s
-
-
- Dump out only the schema (definitions), no data.
-
-
-
-
-
-
- -t table
-
-
- Dump data for table only.
-
-
-
-
-
-
- -u
-
-
- Use password authentication. Prompts for username and password.
-
-
-
-
-
-
- -v
-
-
- Specifies verbose mode
-
-
-
-
-
-
- -x
-
-
- Prevent dumping of ACLs (grant/revoke commands) and table ownership information.
-
-
-
-
-
-
- the following command line arguments for connection parameters:
-
-
-
-
- -h host
-
-
- Specifies the hostname of the machine on which the
- is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-
-
-
-
-
- -p port
-
-
- Specifies the Internet TCP/IP port or local Unix domain socket file
- extension on which the
postmaster
- is listening for connections. The port number defaults to 5432,
- or the value of the PGPORT
- environment variable (if set).
-
-
-
-
-
-
- -u
-
-
- Use password authentication.
- Prompts for
- username
- and password .
-
-
-
-
-
-
-
-
-
-
- 1998-11-05
-
-
- Outputs
-
-
pg_dump will create a file or
- write to stdout .
-
-
-
-
- Connection to database 'template1' failed.
- connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port 'port '?
-
-
-
pg_dump could not attach to the
- process on the specified host and port. If you see this message,
- ensure that the
postmaster
- 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.
-
-
-
-
-
-
- Connection to database 'dbname ' failed.
- FATAL 1: SetUserId: user 'username ' is not in 'pg_shadow'
-
-
- You do not have a valid entry in the relation pg_shadow
- and and will not be allowed to access
Postgres .
- Contact your
Postgres administrator.
-
-
-
-
-
-
- dumpSequence(table ): SELECT failed
-
-
- You do not have permission to read the database.
- Contact your
Postgres site administrator.
-
-
-
-
-
-
-
-
pg_dump internally executes
- SELECT statements. If you have problems running
- make sure you are able to select information from the database using, for
-
-
-
-
-
-
-
- 1998-11-05
-
-
- Description
-
-
pg_dump is a utility for dumping out a
-
Postgres database into a script file
- containing query commands. The script
- files are in text format and can be used to reconstruct the database,
- even on other machines and other architectures.
- will produce the queries necessary to re-generate all
- user-defined types, functions, tables, indices, aggregates, and
- operators. In addition, all the data is copied out in text format so
- that it can be readily copied in again, as well as imported into tools
- for editing.
-
- is useful for dumping out the contents of a database to move from one
-
Postgres installation to another. After running
- one should examine the output script file for any warnings, especially
- in light of the limitations listed below.
-
-
-
-
-
- 1998-11-05
-
-
- Notes
-
-
pg_dump has a few limitations.
- The limitations mostly stem from
- difficulty in extracting certain meta-information from the system
- catalogs.
-
-
-
-
- partial indices
-
-
- does not understand partial indices. The reason is
- the same as above; partial index predicates are stored as plans.
-
-
-
-
-
-
- large objects
-
-
-
pg_dump does not handle large objects.
- Large objects are ignored and must be dealt with manually.
-
-
-
-
-
-
-
-
-
-
- 1998-11-05
-
-
- Usage
-
- To dump a database of the same name as the user:
-
- % pg_dump > db.out
-
-
+
+
+
+
+ 1998-11-05
+
+
+ Inputs
+
+
pg_dump accepts the following command
+ line arguments:
+
+
+
+ dbname
+
+ Specifies the name of the database to be extracted.
+ dbname
+ defaults to the value of the
+ USER
+ environment variable.
+
+
+
+
+
+ -a
+
+ Dump out only the data, no schema (definitions).
+
+
+
+
+
+ -c
+
+ Clean(drop) schema prior to create.
+
+
+
+
+
+ -d
+
+ Dump data as proper insert strings.
+
+
+
+
+
+ -D
+
+ Dump data as inserts with attribute names
+
+
+
+
+
+ -f filename
+
+ Specifies the output file. Defaults to stdout .
+
+
+
+
+
+ -n
+
+ Suppress double quotes around identifiers unless absolutely necessary.
+ This may cause trouble loading this dumped data if there are reserved words
+ used for identifiers.
+ This was the default behavior in pre-v6.4
pg_dump .
+
+
+
+
+
+ -N
+
+ Include double quotes around identifiers.
+ This is the default.
+
+
+
+
+
+ -o
+
+ Dump object identifiers (
OID s) for every table.
+
+
+
+
+
+ -s
+
+ Dump out only the schema (definitions), no data.
+
+
+
+
+
+ -t table
+
+ Dump data for table only.
+
+
+
+
+
+ -u
+
+ Use password authentication. Prompts for username and password.
+
+
+
+
+
+ -v
+
+ Specifies verbose mode
+
+
+
+
+
+ -x
+
+ Prevent dumping of ACLs (grant/revoke commands) and table ownership information.
+
+
+
+
+
+
+ the following command line arguments for connection parameters:
+
+
+
+ -h host
+
+ Specifies the hostname of the machine on which the
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+
+
+
+
+
+ -p port
+
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the
postmaster
+ is listening for connections. The port number defaults to 5432,
+ or the value of the PGPORT
+ environment variable (if set).
+
+
+
+
+
+ -u
+
+ Use password authentication.
+ Prompts for
+ username
+ and password .
+
+
+
+
+
+
+
+
+
+ 1998-11-05
+
+
+ Outputs
+
+
pg_dump will create a file or
+ write to stdout .
+
+
+
+
+Connection to database 'template1' failed.
+connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port 'port '?
+
+
+
pg_dump could not attach to the
+ process on the specified host and port. If you see this message,
+ ensure that the
postmaster
+ 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.
+
+
+
+
+
+
+Connection to database 'dbname ' failed.
+FATAL 1: SetUserId: user 'username ' is not in 'pg_shadow'
+
+
+ You do not have a valid entry in the relation pg_shadow
+ and and will not be allowed to access
Postgres .
+ Contact your
Postgres administrator.
+
+
+
+
+
+
+dumpSequence(table ): SELECT failed
+
+
+ You do not have permission to read the database.
+ Contact your
Postgres site administrator.
+
+
+
+
+
+
+
- To reload this database:
-
- psql -e database < db.out
-
+
pg_dump internally executes
+ SELECT statements. If you have problems running
+ make sure you are able to select information from the database using, for
-
-
+
+
+
+
+
+
+ 1998-11-05
+
+
+ Description
+
+
pg_dump is a utility for dumping out a
+
Postgres database into a script file
+ containing query commands. The script
+ files are in text format and can be used to reconstruct the database,
+ even on other machines and other architectures.
+ will produce the queries necessary to re-generate all
+ user-defined types, functions, tables, indices, aggregates, and
+ operators. In addition, all the data is copied out in text format so
+ that it can be readily copied in again, as well as imported into tools
+ for editing.
+
+
+ is useful for dumping out the contents of a database to move from one
+
Postgres installation to another. After running
+ one should examine the output script file for any warnings, especially
+ in light of the limitations listed below.
+
+
+
+
+
+ 1998-11-05
+
+
+ Notes
+
+
pg_dump has a few limitations.
+ The limitations mostly stem from
+ difficulty in extracting certain meta-information from the system
+ catalogs.
+
+
+
+ does not understand partial indices. The reason is
+ the same as above; partial index predicates are stored as plans.
+
+
+
+
+
pg_dump does not handle large objects.
+ Large objects are ignored and must be dealt with manually.
+
+
+
+
+
+
+
+
+ 1998-11-05
+
+
+ Usage
+
+ To dump a database of the same name as the user:
+
+% pg_dump > db.out
+
+
+
+ To reload this database:
+
+% psql -e database < db.out
+
+
+
+
+
+
-<REFENTRY ID ="APP-PG-DUMPALL">
->
->
->
-Application >
->
->
->
->
->
-Extract all
Postgres databases into a script file
->
-
->
->
-1998-10-04 >
->
->
+<refentry id ="APP-PG-DUMPALL">
+ >
+ >
+ >
+ Application >
+ >
+ >
+ >
+ >
+ >
+
Extract all
Postgres databases into a script file
+ >
+
+ >
+ >
+ 1998-10-04 >
+ >
+ >
pg_dumpall
-pg_dumpall [ -h host ] [ -p port ]
- [ -a ] [ -d ] [ -D ] [ -o ] [ -s ] [ -u ] [ -v ] [ -x ]
-
+pg_dumpall [ -h host ] [ -p port ] [ -a ] [ -d ] [ -D ] [ -o ] [ -s ] [ -u ] [ -v ] [ -x ]
+
-
-
- 1998-10-04
-
-
- Inputs
-
-
pg_dumpall accepts the following command line arguments:
-
-
-
-
- -a
-
-
- Dump out only the data, no schema (definitions).
-
-
-
-
-
- -d
-
-
- Dump data as proper insert strings.
-
-
-
-
-
-
- -D
-
-
- Dump data as inserts with attribute names
-
-
-
-
-
-
- -n
-
-
- Suppress double quotes around identifiers unless absolutely necessary.
- This may cause trouble loading this dumped data if there are reserved words
- used for identifiers.
-
-
-
-
-
-
- -o
-
-
- Dump object identifiers (
OID s) for every table.
-
-
-
-
-
-
- -s
-
-
- Dump out only the schema (definitions), no data.
-
-
-
+
+
+ 1998-10-04
+
+
+ Inputs
+
+
pg_dumpall accepts the following command line arguments:
-
-
- -u
-
-
- Use password authentication. Prompts for username and password.
-
-
-
-
-
-
- -v
-
-
- Specifies verbose mode
-
-
-
-
-
-
- -x
-
-
- Prevent dumping ACLs (grant/revoke commands) and table ownership information.
-
-
-
-
-
-
-
pg_dumpall also accepts
- the following command line arguments for connection parameters:
-
-
-
-
- -h host
-
-
- Specifies the hostname of the machine on which the
- is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-
-
-
-
-
- -p port
-
-
- Specifies the Internet TCP/IP port or local Unix domain socket file
- extension on which the
postmaster
- is listening for connections. The port number defaults to 5432,
- or the value of the PGPORT
- environment variable (if set).
-
-
-
-
-
-
- -u
-
-
- Use password authentication.
- Prompts for
- username
- and password .
-
-
-
-
-
-
+
+
+ -a
+
+ Dump out only the data, no schema (definitions).
+
+
+
-
-
- 1998-10-04
-
-
- Outputs
-
-
pg_dumpall will create a file or
- write to stdout .
-
-
-
-
- Connection to database 'template1' failed.
- connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port 'port '?
-
-
-
pg_dumpall could not attach to the
- process on the specified host and port. If you see this message,
- ensure that the
postmaster
- 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.
-
-
-
-
-
-
- Connection to database 'dbname ' failed.
- FATAL 1: SetUserId: user 'username ' is not in 'pg_shadow'
-
-
- You do not have a valid entry in the relation pg_shadow
- and and will not be allowed to access
Postgres .
- Contact your
Postgres administrator.
-
-
-
+
+ -d
+
+ Dump data as proper insert strings.
+
+
+
-
-
- dumpSequence(table ): SELECT failed
-
-
- You do not have permission to read the database.
- Contact your
Postgres site administrator.
-
-
-
-
-
+
+ -D
+
+ Dump data as inserts with attribute names
+
+
+
-
-
pg_dumpall internally executes
- SELECT statements. If you have problems running
- make sure you are able to select information from the database using, for
-
-
-
-
-
-
-
- 1998-10-04
-
-
- Description
-
- is a utility for dumping out all Postgres databases into one file.
- It also dumps the pg_shadow table, which is global to all databases.
-
pg_dumpall includes in this file the proper commands
- to automatically create each dumped database before loading.
-
+
+ -n
+
+ Suppress double quotes around identifiers unless absolutely necessary.
+ This may cause trouble loading this dumped data if there are reserved words
+ used for identifiers.
+
+
+
+
+
+ -o
+
+ Dump object identifiers (
OID s) for every table.
+
+
+
+
+
+ -s
+
+ Dump out only the schema (definitions), no data.
+
+
+
+
+
+ -u
+
+ Use password authentication. Prompts for username and password.
+
+
+
+
+
+ -v
+
+ Specifies verbose mode
+
+
+
+
+
+ -x
+
+ Prevent dumping ACLs (grant/revoke commands) and table ownership information.
+
+
+
+
+
+
+
+
pg_dumpall also accepts
+ the following command line arguments for connection parameters:
+
+
+
+ -h host
+
+ Specifies the hostname of the machine on which the
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+
+
+
+
+
+ -p port
+
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the
postmaster
+ is listening for connections. The port number defaults to 5432,
+ or the value of the PGPORT
+ environment variable (if set).
+
+
+
+
+
+ -u
+
+ Use password authentication.
+ Prompts for
+ username
+ and password .
+
+
+
+
+
+
+
+
+
+ 1998-10-04
+
+
+ Outputs
+
+
pg_dumpall will create a file or
+ write to stdout .
+
+
+
+
+Connection to database 'template1' failed.
+connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port 'port '?
+
+
+
pg_dumpall could not attach to the
+ process on the specified host and port. If you see this message,
+ ensure that the
postmaster
+ 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.
+
+
+
+
+
+
+Connection to database 'dbname ' failed.
+FATAL 1: SetUserId: user 'username ' is not in 'pg_shadow'
+
+
+ You do not have a valid entry in the relation pg_shadow
+ and and will not be allowed to access
Postgres .
+ Contact your
Postgres administrator.
+
+
+
+
+
+
+dumpSequence(table ): SELECT failed
+
+
+ You do not have permission to read the database.
+ Contact your
Postgres site administrator.
+
+
+
+
+
+
+
-
pg_dumpall takes all
pg_dump
- options, but -f , -t and
- dbname
- should be omitted.
+
pg_dumpall internally executes
+ SELECT statements. If you have problems running
+ make sure you are able to select information from the database using, for
- Refer to
-
- for more information on this capability.
-
-
+
+
+
-
-
- 1998-10-04
-
-
- Usage
-
- To dump all databases:
+
+
+ 1998-10-04
+
+
+ Description
+
+ is a utility for dumping out all Postgres databases into one file.
+ It also dumps the pg_shadow table, which is global to all databases.
+
pg_dumpall includes in this file the proper commands
+ to automatically create each dumped database before loading.
+
+
pg_dumpall takes all
pg_dump
+ options, but -f , -t and
+ dbname
+ should be omitted.
+
+ Refer to
+
+ for more information on this capability.
+
+
- % pg_dumpall -o > db.out
-
+
+
+ 1998-10-04
+
+
+ Usage
+
+ To dump all databases:
-
- You can use most
pg_dump options
-
-
-
+% pg_dumpall -o > db.out
+
+
+
- To reload this database:
-
- psql -e template1 < db.out
-
+ You can use most
pg_dump options
-
- You can use most
psql options
- when reloading.
-
-
-
-
+
+
+ To reload this database:
+
+% psql -e template1 < db.out
+
+
+
+ You can use most
psql options
+ when reloading.
+
+
+
+
+
+
-<REFENTRY ID ="APP-PG-UPGRADE">
->
->
->
-Application >
->
->
->
->
->
-Allows upgrade from a previous release without reloading data
->
->
->
-1998-10-04 >
->
->
+<refentry id ="APP-PG-UPGRADE">
+ >
+ >
+ >
+ Application >
+ >
+ >
+ >
+ >
+ >
+ Allows upgrade from a previous release without reloading data
+ >
+ >
+ >
+ 1998-10-04 >
+ >
+ >
pg_upgrade
-pg_upgrade [-f input_file ] old_data_dir
-
-
-
-
-1998-10-04
-
-
-Description
-
- is a utility for upgrading from a previous
- PostgreSQL release without reloading all the data. First,
- to be safe, back up your data directory. Then, use:
+pg_upgrade [ -f filename ] old_data_dir
+
+
+
+
+
+ 1998-10-04
+
+
+ Description
+
+ is a utility for upgrading from a previous
+ PostgreSQL release without reloading all the data.
+
+
+
+ Back up your data directory.
+
+
+
+
+ Use:
% pg_dumpall -s >db.out
-
-to dump out your old database definitions without any
-data. Stop the postmaster and all backends.
-
-
-Then rename (using mv) your old pgsql /data directory to
-/data.old and do a make install to install the new binaries.
-Run initdb to create a new template1 database containing the system
-tables for the new release. Start the new postmaster, cd to the
-pgsql main directory, and type:
+
+ to dump out your old database definitions without any
+ data. Stop the postmaster and all backends.
+
+
+
+
+ Rename (using mv) your old pgsql data/ directory to
+ data.old/ .
+
+
+
+
+ Do a
+ make install to install the new binaries.
+
+
+
+
+ Run
initdb to create a new template1 database containing the system
+ tables for the new release.
+
+
+
+
+ Start the new postmaster.
+
+
+
+
+ Change your working directory to the
+ pgsql main directory, and type:
% pg_upgrade -f db.out data.old
-
-The system will do some checking to make sure everything
-is properly configured, and run your db.out script to create
-all the databases and tables you had, but with no
-data. It will then move the data files from /data.old
-into the proper /data directory. You can then check out
-the data. You can delete the /data.old directory when you
-are finished.
-
+
+ The system will do some checking to make sure everything
+ is properly configured, and will run your db.out script to create
+ all the databases and tables you had, but with no
+ data. It will then move the data files from data.old/
+ into the proper data/ directory.
+
+
+
+
+ Carefully examine the contents of the upgraded database.
+
+
+
+
+ You can delete the data.old/ directory when you
+ are finished.
+
+
+
+
+
-<REFENTRY ID ="APP-PGACCESS">
- <REFMETA >
- <REFENTRYTITLE id="pgaccess-ref">
+<refentry id ="APP-PGACCESS">
+ <refmeta >
+ <refentrytitle id="pgaccess-ref">
- REFENTRYTITLE >
- <REFMISCINFO>Application>
- REFMETA >
- <REFNAMEDIV >
- <REFNAME >
+ refentrytitle >
+ <refmiscinfo>Application>
+ refmeta >
+ <refnamediv >
+ <refname >
- REFNAME >
- <REFPURPOSE >
+ refname >
+ <refpurpose >
Postgres graphical interactive client
- REFPURPOSE >
+ refpurpose >
- <REFSYNOPSISDIV >
- <REFSYNOPSISDIVINFO >
- <DATE>1999-05-19>
- REFSYNOPSISDIVINFO >
- <SYNOPSIS >
+ <refsynopsisdiv >
+ <refsynopsisdivinfo >
+ <date>1999-05-19>
+ refsynopsisdivinfo >
+ <synopsis >
pgaccess [ dbname ]
- SYNOPSIS >
+ synopsis >
- <REFSECT2 ID ="R2-APP-PGACCESS-1">
- <REFSECT2INFO >
- <DATE>1999-05-19>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-APP-PGACCESS-1">
+ <refsect2info >
+ <date>1999-05-19>
+ refsect2info >
+ <title >
Inputs
-
+
+
+
+
+ dbname
+
+ The name of an existing database to access.
+
+
+
+
- <REFSECT2 ID ="R2-APP-PGACCESS-2">
- <REFSECT2INFO >
- <DATE>1999-05-19>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-APP-PGACCESS-2">
+ <refsect2info >
+ <date>1999-05-19>
+ refsect2info >
+ <title >
Outputs
- TITLE >
- <PARA >
+ title >
+ <para >
- <REFSECT1 ID ="R1-APP-PGACCESS-1">
- <REFSECT1INFO >
- <DATE>1999-05-19>
- REFSECT1INFO >
- <TITLE >
+ <refsect1 id ="R1-APP-PGACCESS-1">
+ <refsect1info >
+ <date>1999-05-19>
+ refsect1info >
+ <title >
Description
-
+
+
+
Editor's Note
+ This should be transcribed from other pgaccess info. Volunteers?
+
+
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
-sgml-local-catalogs:"/usr/lib/sgml/CATALOG "
+sgml-local-catalogs:"/usr/lib/sgml/catalog "
sgml-local-ecat-files:nil
End:
-->
-<REFENTRY ID ="APP-PGADMIN">
- <REFMETA >
- <REFENTRYTITLE id="pgadmin-ref">
+<refentry id ="APP-PGADMIN">
+ <refmeta >
+ <refentrytitle id="pgadmin-ref">
- REFENTRYTITLE >
- <REFMISCINFO>Application>
- REFMETA >
- <REFNAMEDIV >
- <REFNAME >
+ refentrytitle >
+ <refmiscinfo>Application>
+ refmeta >
+ <refnamediv >
+ <refname >
- REFNAME >
- <REFPURPOSE >
+ refname >
+ <refpurpose >
Postgres graphical interactive client
- REFPURPOSE >
+ refpurpose >
- <REFSYNOPSISDIV >
- <REFSYNOPSISDIVINFO >
- <DATE>1999-05-19>
- REFSYNOPSISDIVINFO >
- <SYNOPSIS >
+ <refsynopsisdiv >
+ <refsynopsisdivinfo >
+ <date>1999-05-19>
+ refsynopsisdivinfo >
+ <synopsis >
pgadmin [ dbname ]
- SYNOPSIS >
+ synopsis >
- <REFSECT2 ID ="R2-APP-PGADMIN-1">
- <REFSECT2INFO >
- <DATE>1999-05-19>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-APP-PGADMIN-1">
+ <refsect2info >
+ <date>1999-05-19>
+ refsect2info >
+ <title >
Inputs
-
+
+
+
+
+ dbname
+
+ The name of an existing database to access.
+
+
+
+
- <REFSECT2 ID ="R2-APP-PGADMIN-2">
- <REFSECT2INFO >
- <DATE>1999-05-19>
- REFSECT2INFO >
- <TITLE >
+ <refsect2 id ="R2-APP-PGADMIN-2">
+ <refsect2info >
+ <date>1999-05-19>
+ refsect2info >
+ <title >
Outputs
- TITLE >
- <PARA >
+ title >
+ <para >
- <REFSECT1 ID ="R1-APP-PGADMIN-1">
- <REFSECT1INFO >
- <DATE>1999-05-19>
- REFSECT1INFO >
- <TITLE >
+ <refsect1 id ="R1-APP-PGADMIN-1">
+ <refsect1info >
+ <date>1999-05-19>
+ refsect1info >
+ <title >
Description
-
+
+
+
Editor's Note
+ This should be transcribed from other pgadmin info. Volunteers?
+
+
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
-sgml-local-catalogs:"/usr/lib/sgml/CATALOG "
+sgml-local-catalogs:"/usr/lib/sgml/catalog "
sgml-local-ecat-files:nil
End:
-->
-
- dbname
-
+ dbname
The optional argument
-
- -B nBuffers
-
+ -B nBuffers
If the backend is running under the
-
- -C
-
+ -C
Do not show the server version number.
-
- -D DataDir
-
+ -D DataDir
Specifies the directory to use as the root of the tree of database
-
- -E
-
+ -E
Echo all queries.
-
- -F
-
+ -F
Disable an automatic fsync() call after each transaction.
-
- -O
-
+ -O
Override restrictions, so system table structures can be modified.
-
- -Q
-
+ -Q
Specifies "quiet" mode.
-
- -S SortSize
-
+ -S SortSize
Specifies the amount of memory to be used by internal sorts and hashes
-
- -d [ DebugLevel ]
-
+ -d [ DebugLevel ]
The optional argument DebugLevel
-
- -e
-
+ -e
This option controls how dates are interpreted upon
-
- -o OutputFile
-
+ -o OutputFile
Sends all debugging and error output to
-
- -s
-
+ -s
Print time information and other statistics at the end of each query.
-
- -v protocol
-
+ -v protocol
Specifies the number of the frontend/backend protocol to be used for this
-
- -A n|r|b|Q\fIn\fP|X\fIn\fP
-
+ -A n|r|b|Q\fIn\fP|X\fIn\fP
This option generates a tremendous amount of output.
-
- -L
-
+ -L
Turns off the locking system.
-
- -N
-
+ -N
Disables use of newline as a query delimiter.
-
- -f [ s | i | m | n | h ]
-
+ -f [ s | i | m | n | h ]
Forbids the use of particular scan and join methods:
-
- -i
-
+ -i
Prevents query execution, but shows the plan tree.
-
- -p dbname
-
+ -p dbname
Indicates to the backend server that it has been started by a
-
- -t pa[rser] | pl[anner] | e[xecutor]
-
+ -t pa[rser] | pl[anner] | e[xecutor]
Print timing statistics for each query relating to each of the major
-
- semget: No space left on device
-
+
+semget: No space left on device
+
If you see this message, you should run the
-
- -B nBuffers
-
+ -B nBuffers
The number of shared-memory buffers for the
-
- -D DataDir
-
+ -D DataDir
Specifies the directory to use as the root of the tree of database
-
- -N nBackends
-
+ -N nBackends
The maximum number of backend server processes that this postmaster
-
- -S
-
+ -S
Specifies that the
postmaster
-
- -d [ DebugLevel ]
-
+ -d [ DebugLevel ]
The optional argument DebugLevel
-
- -i
-
+ -i
This enables TCP/IP or Internet domain socket communication.
-
- -o BackendOptions
-
+ -o BackendOptions
The
-
- -p port
-
+ -p port
Specifies the TCP/IP port or local Unix domain socket file extension
-
- -n
-
+ -n
-
- -s
-
+ -s
-->
-
- semget: No space left on device
-
+
+semget: No space left on device
+
If you see this message, you should run the
-
- StreamServerPort: cannot bind to port
-
+
+StreamServerPort: cannot bind to port
+
If you see this message, you should be certain that there is no other
-
- IpcMemoryAttach: shmat() failed: Permission denied
-
+
+IpcMemoryAttach: shmat() failed: Permission denied
+
A likely explanation is that another user attempted to start a
psql [ dbname ]
psql -A [ -c query ] [ -d dbname ]
- -e -E [ -f filename ]
- [ -F separator ] [ -h hostname ]
- -Hln [ -o filename ] [ -p
-port ]
- -qsSt [ -T table_o ] -ux
+ -e -E [ -f filename ] [ -F separator ]
+ [ -h hostname ] -Hln [ -o filename ]
+ [ -p port ] -qsSt [ -T table_o ] -ux
[ dbname ]
-
- dbname
-
+ dbname
The name of an existing database to access.
-
- -c query
-
+ -c query
A single query to run.
psql will exit on completion.
-
+
The full set of command-line arguments and meta-commands are described in a subsequent
section.
+
There are some environment variables which can be used in liu of
command line arguments.
-
- PGHOST
-
+ PGHOST
The
DNS host name of the database server.
-
- PGPORT
-
+ PGPORT
The port number on which a
Postgres server is listening.
-
- PGTTY
-
+ PGTTY
The target for display of messages from the client support library.
-
- PGOPTION
-
+ PGOPTION
If PGOPTION
-
- PGREALM
-
+ PGREALM
PGREALM
returns 0 to the shell on successful completion of all queries,
1 for errors, 2 for abrupt disconnection from the backend.
- The default TAB delimiter is used.
will also return 1 if the connection to a database could not be made for
any reason.
+ The default TAB delimiter is used.
+
-
- -A
-
+ -A
Turn off fill justification when printing out table elements.
-
- -c query
-
+ -c query
Specifies that
-
- -d dbname
-
+ -d dbname
Specifies the name of the database to connect to. This is equivalent to specifying
-
- -e
-
+ -e
Echo the query sent to the backend
-
- -E
-
+ -E
Echo the actual query generated by \d and other backslash commands
-
- -f filename
-
+ -f filename
Use the file filename
-
- -F separator
-
+ -F separator
Use separator
-
- -h hostname
-
+ -h hostname
Specifies the host name of the machine on which the
-
- -H
-
+ -H
Turns on
-
- -l
-
+ -l
Lists all available databases, then exit. Other non-connection options are ignored.
-
- -n
-
+ -n
Do not use the readline library for input line editing and command history.
-
- -o filename
-
+ -o filename
Put all output into file filename .
-
- -p port
-
+ -p port
Specifies the TCP/IP port or, by omission, the local Unix domain socket file
-
- -q
-
+ -q
Specifies that
-
- -s
-
+ -s
Run in single-step mode where the user is prompted for each query before
-
- -S
-
+ -S
Runs in single-line mode where each query is terminated by a newline,
-
- -t
-
+ -t
Turn off printing of column names.
-
- -T table_options
-
+ -T table_options
Allows you to specify options to be placed within the
-
- -u
-
+ -u
Asks the user for the user name and password before connecting to the database.
-
- -x
-
+ -x
Turns on extended row format mode. When enabled each row will have its column
-
- \a
-
+ \a
Toggle field alignment when printing out table elements.
-
- \C caption
-
+ \C caption
Set the HTML3.0 table caption to
-
-
\connect meter" ceable> [
- class="parameter">username ]
-
+ \connect meter" ceable> [ username ]
Establish a connection to a new database, using the default
-
- \copy meter" ceable> { FROM | TO }
- filename
+ \copy meter" ceable> { FROM | TO } filename
-
- \d [ table ]
-
+ \d [ table ]
List tables in the database, or if
-
- \da
-
+ \da
List all available aggregates.
-
- \dd object
-
+ \dd object
List the description from pg_description
-
- \df
-
+ \df
List functions.
-
- \di
-
+ \di
List only indexes.
-
- \do
-
+ \do
List only operators.
-
- \ds
-
+ \ds
List only sequences.
-
- \dS
-
+ \dS
List system tables and indexes.
-
- \dt
-
+ \dt
List only non-system tables.
-
- \dT
-
+ \dT
List types.
-
-
- \e [ filename ]
-
+
+ \e [ filename ]
Edit the current query buffer or the contents of the file
-
- \E [ filename ]
-
+ \E [ filename ]
Edit the current query buffer or the contents of the file
-
- \f [ separator ]
-
+ \f [ separator ]
Set the field separator. Default is a single blank space.
-
- \g [ { filename | | command } ]
-
+ \g [ { filename | | command } ]
Send the current query input buffer to the backend and optionally
-
- \h [ command ]
-
+ \h [ command ]
Give syntax help on the specified SQL command.
-
- \H
-
+ \H
Toggle
HTML3 output. This is equivalent to
-
- \i filename
-
+ \i filename
Read queries from the file filename
-
- \l
-
+ \l
List all the databases in the server.
-
- \m
-
+ \m
Toggle the old monitor-like table display, which includes border characters
-
- \o [ { filename | | command } ]
-
+ \o [ { filename | | command } ]
Save future query results to the file
-
- \p
-
+ \p
Print the current query buffer.
-
- \q
-
+ \q
-
- \r
-
+ \r
Reset(clear) the query buffer.
-
- \s [ filename ]
-
+ \s [ filename ]
Print or save the command line history to
-
- \t
-
+ \t
Toggle display of output column name headings and row count footer (defaults to on).
-
- \T table_options
-
+ \T table_options
Allows you to specify options to be placed within the
-
- \x
-
+ \x
Toggles extended row format mode. When enabled each row will have its column
-
- \w filename
-
+ \w filename
Outputs the current query buffer to the file
-
- \z
-
+ \z
Produces a list of all tables in the database with their appropriate ACLs
-
- \! [ command ]
-
+ \! [ command ]
Escape to a separate Unix shell or execute the Unix command
-
- \?
-
+ \?
Get help information about the slash (\
) commands.
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
-sgml-local-catalogs:"/usr/lib/sgml/CATALOG "
+sgml-local-catalogs:"/usr/lib/sgml/catalog "
sgml-local-ecat-files:nil
End:
-->
-
- variable
-
+ variable
Refer to the SET statement for more information on available
-
- RESET VARIABLE
-
+
+RESET VARIABLE
+
Message returned if
Usage
+ Set DateStyle to its default value:
+
--- reset DateStyle to its default;
RESET DateStyle;
+
+
+ Set Geqo to its default value:
+
--- reset Geqo to its default;
RESET GEQO;
-
- privilege
-
+ privilege
The possible privileges are:
-
-
-
-
-
- SELECT
-
-
- Privilege to access all of the columns of a specific
- table/view.
-
-
-
+
+
+ SELECT
+
+ Privilege to access all of the columns of a specific
+ table/view.
+
+
+
-
-
- INSERT
-
-
- Privilege to insert data into all columns of a
- specific table.
-
-
-
+
+ INSERT
+
+ Privilege to insert data into all columns of a
+ specific table.
+
+
+
-
-
- UPDATE
-
-
- Privilege to update all columns of a specific
- table.
-
-
-
+
+ UPDATE
+
+ Privilege to update all columns of a specific
+ table.
+
+
+
-
-
- DELETE
-
-
- Privilege to delete rows from a specific table.
-
-
-
+
+ DELETE
+
+ Privilege to delete rows from a specific table.
+
+
+
-
-
- RULE
-
-
- Privilege to define rules on table/view.
- (See CREATE RULE ).
-
-
-
+
+ RULE
+
+ Privilege to define rules on table/view.
+ (See CREATE RULE ).
+
+
+
-
-
- ALL
-
-
- Rescind all privileges.
+
+ ALL
+
+ Rescind all privileges.
+
+
+
+
-
- object
-
+ object
The name of an object from which to revoke access.
+
The possible objects are:
-
- group
-
+ group
The name of a group from whom to revoke privileges.
-
- username
-
+ username
The name of a user from whom revoke privileges. Use the PUBLIC keyword
-
- PUBLIC
-
+ PUBLIC
Rescind the specified privilege(s) for all users.
-
- CHANGE
-
+
+CHANGE
+
Message returned if successfully.
-
- ERROR
-
+
+ERROR
+
Message returned if object is not available or impossible
Description
- REVOKE allows creator of an object to revoke permissions granted
+ REVOKE allows creator of an object to revoke permissions granted
before, from all users (via PUBLIC) or a certain user or group.
Currently, to create a GROUP you have to insert
data manually into table pg_group as:
+
INSERT INTO pg_group VALUES ('todos');
CREATE USER miriam IN GROUP todos;
Usage
+ Revoke insert privilege from all users on table
+ films :
+
--- revoke insert privilege from all users on table films:
---
REVOKE INSERT ON films FROM PUBLIC;
+
+
+ Revoke all privileges from user manuel on view kinds :
--- revoke all privileges from user manuel on view kinds:
---
REVOKE ALL ON kinds FROM manuel;
+
The possible objects are:
and user2 gives it to user3 then user1 can revoke
this privilege in cascade using the CASCADE keyword.
+
If user1 gives a privilege WITH GRANT OPTION to user2,
and user2 gives it to user3 then if user1 try revoke
-ROLLBACK
+ ROLLBACK
SQL - Language Statements
-ROLLBACK
+ ROLLBACK
Aborts the current transaction
-
- ABORT
-
+
+ABORT
+
Message returned if successful.
-
- NOTICE: UserAbortTransactionBlock and not in in-progress state
- ABORT
-
+
+NOTICE: UserAbortTransactionBlock and not in in-progress state
+ABORT
+
If there is not any transaction currently in progress.
Usage
+ To abort all changes:
+
- --To abort all changes:
- --
- ROLLBACK WORK;
+ROLLBACK WORK;
SQL92
- Full compatibility. TRANSACTION is a
+ Full compatibility. The TRANSACTION keyword is a