- <REFENTRY ID="SQL-ALTERUSER">
- <REFMETA>
- <REFENTRYTITLE>
+ <refentry id="SQL-ALTERUSER">
+ <refmeta>
+ <refentrytitle>
ALTER USER
- REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements>
- REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ refentrytitle>
+ <refmiscinfo>SQL - Language Statements>
+ refmeta>
+ <refnamediv>
+ <refname>
ALTER USER
- REFNAME>
- <REFPURPOSE>
+ refname>
+ <refpurpose>
Modifies user account information
- REFPURPOSE>
+ refpurpose>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-08>
- REFSYNOPSISDIVINFO>
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-08>
+ refsynopsisdivinfo>
ALTER USER username
[ WITH PASSWORD password ]
[ VALID UNTIL 'abstime' ]
- <REFSECT2 ID="R2-SQL-ALTERUSER-1">
- <REFSECT2INFO>
- <DATE>1998-09-08>
- REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-ALTERUSER-1">
+ <refsect2info>
+ <date>1998-09-08>
+ refsect2info>
+ <title>
Inputs
- TITLE>
- <PARA>
+ title>
+ <para>
Refer to CREATE USER for a detailed description of each
clause.
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER"> username >
- TERM>
- <LISTITEM>
- <PARA>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <replaceable class="PARAMETER"> username >
+ term>
+ <listitem>
+ <para>
The Postgres account name of the user whose details are to be altered.
- PARA>
- LISTITEM>
- VARLISTENTRY>
+ para>
+ listitem>
+ varlistentry>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER"> password >
- TERM>
- <LISTITEM>
- <PARA>
+ <varlistentry>
+ <term>
+ <replaceable class="PARAMETER"> password >
+ term>
+ <listitem>
+ <para>
The new password to be used for this account.
- PARA>
- LISTITEM>
- VARLISTENTRY>
+ para>
+ listitem>
+ varlistentry>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER"> groupname >
- TERM>
- <LISTITEM>
- <PARA>
+ <varlistentry>
+ <term>
+ <replaceable class="PARAMETER"> groupname >
+ term>
+ <listitem>
+ <para>
The name of an access group into which this account is to be put.
- PARA>
- LISTITEM>
- VARLISTENTRY>
+ para>
+ listitem>
+ varlistentry>
- <VARLISTENTRY>
- <TERM>
- <REPLACEABLE CLASS="PARAMETER"> abstime >
- TERM>
- <LISTITEM>
- <PARA>
+ <varlistentry>
+ <term>
+ <replaceable class="PARAMETER"> abstime >
+ term>
+ <listitem>
+ <para>
The date (and, optionally, the time)
at which this user's access is to be terminated.
- PARA>
- LISTITEM>
- VARLISTENTRY>
- VARIABLELIST>
- REFSECT2>
+ para>
+ listitem>
+ varlistentry>
+ variablelist>
+ refsect2>
- <REFSECT2 ID="R2-SQL-ALTERUSER-2">
- <REFSECT2INFO>
- <DATE>1998-09-08>
- REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-ALTERUSER-2">
+ <refsect2info>
+ <date>1998-09-08>
+ refsect2info>
+ <title>
Outputs
- TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
+ title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term>
ALTER USER
- TERM>
- <LISTITEM>
- <PARA>
+ term>
+ <listitem>
+ <para>
Message returned if the alteration was successful.
- PARA>
- LISTITEM>
- VARLISTENTRY>
+ para>
+ listitem>
+ varlistentry>
- <VARLISTENTRY>
- <TERM>
+ <varlistentry>
+ <term>
ERROR: alterUser: user "username" does not exist
- TERM>
- <LISTITEM>
- <PARA>
+ term>
+ <listitem>
+ <para>
Error message returned if the user specified doesn't
exist.
- REFSECT2>
- REFSYNOPSISDIV>
+ refsect2>
+ refsynopsisdiv>
- <REFSECT1 ID="R1-SQL-ALTERUSER-1">
- <REFSECT1INFO>
- <DATE>1998-09-08>
- REFSECT1INFO>
- <TITLE>
+ <refsect1 id="R1-SQL-ALTERUSER-1">
+ <refsect1info>
+ <date>1998-09-08>
+ refsect1info>
+ <title>
Description
- TITLE>
- <PARA>
+ title>
+ <para>
ALTER USER is used to change the attributes of a user's
Please note that it is not possible
user or any user with read and modify permissions on
"pg_shadow" to alter user passwords.
- PARA>
+ para>
If any of the clauses of the alter user statement are
omitted, the corresponding value in the "pg_shadow" table
is left unchanged.
- <REFSECT2 ID="R2-SQL-ALTERUSER-3">
- <REFSECT2INFO>
- <DATE>1998-09-08>
- REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-ALTERUSER-3">
+ <refsect2info>
+ <date>1998-09-08>
+ refsect2info>
+ <title>
Notes
- TITLE>
- <PARA>
+ title>
+ <para>
ALTER USER statement
language extension.
account.
- In the current release (v6.4), the IN GROUP clause is parsed
+ 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.
- REFSECT2>
+ refsect2>
- <REFSECT1 ID="R1-SQL-ALTERUSER-2">
- <TITLE>
+ <refsect1 id="R1-SQL-ALTERUSER-2">
+ <title>
Usage
- TITLE>
- <PARA>
+ title>
+ <para>
Change a user password
- PARA>
- <ProgramListing>
+ para>
+ <programlisting>
ALTER USER davide WITH PASSWORD hu8jmn3;
- ProgramListing>
+ programlisting>
Change a user's valid until date
- <ProgramListing>
+ <programlisting>
ALTER USER manuel VALID UNTIL 'Jan 31 2030';
- ProgramListing>
+ programlisting>
Change a user's valid until date, specifying that his
authorisation should expire at midday on 4th May 1998 using
the time zone which is one hour ahead of UTC
- <ProgramListing>
+ <programlisting>
ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
- ProgramListing>
+ programlisting>
Give a user the ability to create other users and new databases.
ALTER USER miriam IN GROUP sales, payroll;
- REFSECT1>
+ refsect1>
- <REFSECT1 ID="R1-SQL-ALTERUSER-3">
- <TITLE>
+ <refsect1 id="R1-SQL-ALTERUSER-3">
+ <title>
Compatibility
- TITLE>
- <PARA>
- PARA>
+ title>
+ <para>
+ para>
- <REFSECT2 ID="R2-SQL-ALTERUSER-4">
- <REFSECT2INFO>
- <DATE>1998-09-08>
- REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-ALTERUSER-4">
+ <refsect2info>
+ <date>1998-09-08>
+ refsect2info>
+ <title>
SQL92
- TITLE>
- <PARA>
+ title>
+ <para>
There is no ALTER USER statement in
The standard leaves
the definition of users to the implementation.
- PARA>
+ para>
- REFENTRY>
+ refentry>
- <REFSECT3 ID="R3-SQL-CONSTRAINT-3">
- <REFSECT3INFO>
- <DATE>1998-09-11>
- REFSECT3INFO>
- <TITLE>
+ <refsect3 id="R3-SQL-CONSTRAINT-3">
+ <refsect3info>
+ <date>1998-09-11>
+ refsect3info>
+ <title>
CONSTRAINT clause
- TITLE>
- <PARA>
+ title>
+ <para>
SQL92 specifies some additional capabilities for constraints,
and also defines assertions and domain constraints.
- <PARA>
+ <para>
An assertion is a special type of integrity constraint and share
the same namespace as other constraints.
However, an assertion is not necessarily dependent on one
CREATE ASSERTION name CHECK ( condition )
- <PARA>
+ <para>
Domain constraints are defined by CREATE DOMAIN or ALTER DOMAIN
statements:
- <PARA>
+ <para>
Domain constraint:
- <REFSECT3 ID="R3-SQL-CHECK-4">
- <REFSECT3INFO>
- <DATE>1998-09-11>
- REFSECT3INFO>
- <TITLE>
+ <refsect3 id="R3-SQL-CHECK-4">
+ <refsect3info>
+ <date>1998-09-11>
+ refsect3info>
+ <title>
CHECK clause
- TITLE>
- <PARA>
+ title>
+ <para>
SQL92 specifies some additional capabilities for CHECK in either
table or column constraints.
- PARA>
+ para>
-<REFENTRY ID="SQL-CREATEUSER">
- <REFMETA>
- <REFENTRYTITLE>
+<refentry id="SQL-CREATEUSER">
+ <refmeta>
+ <refentrytitle>
CREATE USER
- REFENTRYTITLE>
- <REFMISCINFO>SQL - Language Statements>
- REFMETA>
- <REFNAMEDIV>
- <REFNAME>
+ refentrytitle>
+ <refmiscinfo>SQL - Language Statements>
+ refmeta>
+ <refnamediv>
+ <refname>
CREATE USER
- REFNAME>
- <REFPURPOSE>
+ refname>
+ <refpurpose>
Creates account information for a new user
- REFPURPOSE>
+ refpurpose>
- <REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-21>
- REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-CREATE USER<REPLACEABLE CLASS="PARAMETER"> username>
- [ WITH PASSWORD <REPLACEABLE CLASS="PARAMETER">password> ]
+ <refsynopsisdiv>
+ <refsynopsisdivinfo>
+ <date>1998-09-21>
+ refsynopsisdivinfo>
+ <synopsis>
+CREATE USER<replaceable class="PARAMETER"> username>
+ [ WITH PASSWORD <replaceable class="PARAMETER">password> ]
[ CREATEDB | NOCREATEDB ]
[ CREATEUSER | NOCREATEUSER ]
- [ IN GROUP <REPLACEABLE CLASS="PARAMETER">groupname> [, ...] ]
- [ VALID UNTIL '<REPLACEABLE CLASS="PARAMETER">abstime>' ]
- SYNOPSIS>
+ [ IN GROUP <replaceable class="PARAMETER">groupname> [, ...] ]
+ [ VALID UNTIL '<replaceable class="PARAMETER">abstime>' ]
+ synopsis>
- <REFSECT2 ID="R2-SQL-CREATEUSER-1">
- <REFSECT2INFO>
- <DATE>1998-09-21>
- REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEUSER-1">
+ <refsect2info>
+ <date>1998-09-21>
+ refsect2info>
+ <title>
Inputs
-
-
-
-
- username
-
-
- The name of the user.
-
-
-
-
-
- password
-
-
- The WITH PASSWORD clause sets the user's password within
- the "pg_shadow" table. For this reason,
- "pg_shadow" is no
- longer accessible to the instance of
Postgres that the
-
Postgres user's password is initially set to NULL.
- The text here has got garbled.
- When a
- user's password in the "pg_shadow"
- table is NULL, user
- authentication proceeds as it historically has (HBA,
- PG_PASSWORD, etc). However, if a password is set for a
- user, a new authentication system supplants any other
- configured for the
Postgres instance, and the password
- stored in the "pg_shadow" table is used
- for authentication.
- For more details on how this authentication system
- functions see pg_crypt(3). If the WITH PASSWORD clause is
- omitted, the user's password is set to the empty
- string with equates to a NULL value in the authentication
- system mentioned above.
-
-
-
-
-
- CREATEDB/NOCREATEDB
-
-
- These clauses define a user's ability to create databases.
- If CREATEDB is specified, the user being defined will
- be allowed to create his own databases. Using NOCREATEDB
- will deny a user the ability to create databases. If this
- clause is omitted, NOCREATEDB is used by default.
-
-
-
-
-
- CREATEUSER/NOCREATEUSER
-
-
- These clauses determine whether a user will be permitted to
- create new
- users in an instance of
Postgres.
- Omitting this clause will set the user's value of this
- attribute to be NOCREATEUSER.
-
-
-
-
-
- groupname
-
-
- A name of a group into which to insert the user as a new member.
-
-
-
-
-
- abstime
-
-
- The VALID UNTIL clause sets an absolute time after which the
- user's
Postgres login is no longer valid. Please note that
- if a user does not have a password defined in the
- "pg_shadow"
- table, the valid until date will not be checked
- during user authentication. If this clause is omitted,
- a NULL value is stored in "pg_shadow"
- for this attribute,
- and the login will be valid for all time.
-
-
-
+
+
+
+
+ username
+
+
+ The name of the user.
+
+
+
+
+
+
+ password
+
+
+ The WITH PASSWORD clause sets the user's password within
+ the "pg_shadow" table. For this reason,
+ "pg_shadow" is no
+ longer accessible to the instance of
+ user's password is initially set to NULL.
+
+ When a
+ user's password in the "pg_shadow"
+ table is NULL, user
+ authentication proceeds as it historically has (HBA,
+ PG_PASSWORD, etc). However, if a password is set for a
+ user, a new authentication system supplants any other
+ configured for the
Postgres
+ instance, and the password
+ stored in the "pg_shadow" table is used
+ for authentication.
+ For more details on how this authentication system
+ functions see pg_crypt(3). If the WITH PASSWORD clause is
+ omitted, the user's password is set to the empty
+ string which equates to a NULL value in the authentication
+ system mentioned above.
+
+
+
+
+
+
+ CREATEDB/NOCREATEDB
+
+
+ These clauses define a user's ability to create databases.
+ If CREATEDB is specified, the user being defined will
+ be allowed to create his own databases. Using NOCREATEDB
+ will deny a user the ability to create databases. If this
+ clause is omitted, NOCREATEDB is used by default.
+
+
+
+
+
+
+ CREATEUSER/NOCREATEUSER
+
+
+ These clauses determine whether a user will be permitted to
+ create new
+ users in an instance of
Postgres.
+ Omitting this clause will set the user's value of this
+ attribute to be NOCREATEUSER.
+
+
+
+
+
+
+ groupname
+
+
+ A name of a group into which to insert the user as a new member.
+
+
+
+
+
+
+ abstime
+
+
+ The VALID UNTIL clause sets an absolute time after which the
+ login is no longer valid. Please note that
+ if a user does not have a password defined in the
+ "pg_shadow"
+ table, the valid until date will not be checked
+ during user authentication. If this clause is omitted,
+ a NULL value is stored in "pg_shadow"
+ for this attribute,
+ and the login will be valid for all time.
+
+
+
- REFSECT2>
+ refsect2>
- <REFSECT2 ID="R2-SQL-CREATEUSER-2">
- <REFSECT2INFO>
- <DATE>1998-09-21>
- REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEUSER-2">
+ <refsect2info>
+ <date>1998-09-21>
+ refsect2info>
+ <title>
Outputs
-
-
-
-
-
- CREATE USER
-
-
- Message returned if the command completes successfully.
-
-
-
-
-
- ERROR: removeUser: user "username" does not exist
-
-
- if "username" not found.
-
- I don't understand this and I don't know how to get
- this error message.
-
-
-
-
-
+
+
+
+
+
+ CREATE USER
+
+
+ Message returned if the command completes successfully.
+
+
+
+
+
+
+
ERROR: removeUser: user "
+ class="parameter">username" does not exist
+
+
+ if "username" not found.
+
+ I don't understand this and I don't know how to get
+ this error message.
+
+
+
+
+
+
- <REFSECT1 ID="R1-SQL-CREATEUSER-1">
- <REFSECT1INFO>
- <DATE>1998-09-21>
- REFSECT1INFO>
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEUSER-1">
+ <refsect1info>
+ <date>1998-09-21>
+ refsect1info>
+ <title>
Description
- TITLE>
- <PARA>
+ title>
+ <para>
CREATE USER will add a new user to an instance of
- PARA>
- <PARA>
+ para>
+ <para>
The new user will be given a usesysid of:
'SELECT MAX(usesysid) + 1 FROM pg_shadow'.
This means that
for any given user,
use the "createuser" script provided with the
Postgres
distribution.
- PARA>
+ para>
- <REFSECT2 ID="R2-SQL-CREATEUSER-3">
- <REFSECT2INFO>
- <DATE>1998-09-21>
- REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEUSER-3">
+ <refsect2info>
+ <date>1998-09-21>
+ refsect2info>
+ <title>
Notes
- TITLE>
- <PARA>
+ title>
+ <para>
CREATE USER statement is a
Postgres language extension.
- PARA>
+ para>
Use DROP USER or ALTER USER statements to remove or modify a user
account.
| valuntil | abstime | 4 |
+--------------------------+--------------------------+-------+
- REFSECT2>
+ refsect2>
- <REFSECT1 ID="R1-SQL-CREATEUSER-2">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEUSER-2">
+ <title>
Usage
- TITLE>
- <PARA>
+ title>
+ <para>
Create a user with no password:
- PARA>
- <ProgramListing>
+ para>
+ <programlisting>
CREATE USER jonathan
- ProgramListing>
- <PARA>
+ programlisting>
+ <para>
Create a user with a password:
- PARA>
- <ProgramListing>
+ para>
+ <programlisting>
CREATE USER davide WITH PASSWORD jw8s0F4
- ProgramListing>
+ programlisting>
Create a user with a password, whose account is valid until the end of 2001.
Note that after one second has ticked in 2002, the account is not
valid:
- <ProgramListing>
+ <programlisting>
CREATE USER miriam WITH PASSWORD jw8s0F4 VALID UNTIL 'Jan 1 2002'
- ProgramListing>
+ programlisting>
Create an account where the user can create databases:
- <ProgramListing>
+ <programlisting>
CREATE USER manuel WITH PASSWORD jw8s0F4 CREATEDB
- ProgramListing>
+ programlisting>
- REFSECT1>
+ refsect1>
- <REFSECT1 ID="R1-SQL-CREATEUSER-3">
- <TITLE>
+ <refsect1 id="R1-SQL-CREATEUSER-3">
+ <title>
Compatibility
- TITLE>
- <PARA>
- PARA>
+ title>
+ <para>
+ para>
- <REFSECT2 ID="R2-SQL-CREATEUSER-4">
- <REFSECT2INFO>
- <DATE>1998-09-21>
- REFSECT2INFO>
- <TITLE>
+ <refsect2 id="R2-SQL-CREATEUSER-4">
+ <refsect2info>
+ <date>1998-09-21>
+ refsect2info>
+ <title>
SQL92
- TITLE>
- <PARA>
+ title>
+ <para>
There is no CREATE USER statement in SQL92.
- PARA>
+ para>
-
-
+
-
-
-
-REVOKE
-
-SQL - Language Statements
-
-
-
-REVOKE
-
-
-Revokes access privilege from a user, a group or all users.
-
-
-
-
-1998-09-24
-
-
-
-
-REVOKE privilege [, ...]
- ON object [, ...]
- FROM { PUBLIC | GROUP group | username }
-
+
+
+
+ REVOKE
+
+ SQL - Language Statements
+
+
+
+ REVOKE
+
+
+ Revokes access privilege from a user, a group or all users.
+
+
+
+
+ 1998-09-24
+
+
+REVOKE privilege [, ...]
+ ON object [, ...]
+ FROM { PUBLIC | GROUP ER">gBLE> | username }
+
-
-
- 1998-09-24
-
-
- Inputs
-
-
-
-
-
- privilege
-
-
- The possible privileges are:
-
-
-
+
+
+ 1998-09-24
+
+
+ Inputs
+
-
-
- 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.
-
-
-
-
-
-
- UPDATE
-
-
- Privilege to update all columns of a specific
- table.
-
-
-
-
-
-
- DELETE
-
-
- Privilege to delete rows from a specific table.
-
-
-
-
-
-
- RULE
-
-
- Privilege to define rules on table/view.
- (See CREATE RULE).
-
-
-
-
-
-
- ALL
-
-
- Rescind all privileges.
-
-
-
-
-
-
- object
-
-
- The name of an object from which to revoke access.
- The possible objects are:
-
-
- table
-
-
-
-
- view
-
-
-
-
- sequence
-
-
-
-
- index
-
-
-
-
-
-
-
-
-
- group
-
-
- The name of a group from whom to revoke privileges.
-
-
-
-
-
-
- username
-
-
- The name of a user from whom revoke privileges. Use the PUBLIC keyword
- to specify all users.
-
-
-
-
-
-
- PUBLIC
-
-
- Rescind the specified privilege(s) for all users.
-
-
-
-
-
-
+
+
+
+ privilege
+
+
+ The possible privileges are:
+
+
+
-
-
- 1998-09-24
-
-
- Outputs
-
-
-
-
-
- CHANGE
-
-
- Message returned if successfully.
-
-
-
-
-
-
- ERROR
-
-
- Message returned if object is not available or impossible
- to revoke privileges from a group or users.
-
-
-
-
-
-
-
-
-
-
- 1998-09-24
-
-
- Description
-
- REVOKE allows creator of an object to revoke permissions granted
- before, from all users (via PUBLIC) or a certain user or group.
-
+
+
+ SELECT
+
+
+ Privilege to access all of the columns of a specific
+ table/view.
+
+
+
-
-
- 1998-09-24
-
-
- Notes
-
- Refer to psql \z command for further information about permissions
- on existing objects:
-
- Database = lusitania
- +------------------+---------------------------------------------+
- | Relation | Grant/Revoke Permissions |
- +------------------+---------------------------------------------+
- | mytable | {"=rw","miriam=arwR","group todos=rw"} |
- +------------------+---------------------------------------------+
- Legend:
- uname=arwR -- privileges granted to a user
- group gname=arwR -- privileges granted to a GROUP
- =arwR -- privileges granted to PUBLIC
-
- r -- SELECT
- w -- UPDATE/DELETE
- 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;
-
-
-
+
+
+ INSERT
+
+
+ Privilege to insert data into all columns of a
+ specific table.
+
+
+
-
-
+
+
+ UPDATE
+
+
+ Privilege to update all columns of a specific
+ table.
+
+
+
-
-
- Usage
-
- -- 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 ON kinds FROM manuel;
-
-
-
-
-
-
- Compatibility
-
-
-
-
- 1998-09-01
-
-
- SQL92
-
- The SQL92 syntax for REVOKE
- has additional capabilities for rescinding
- privileges, including those on individual columns in tables:
+
+
+ DELETE
+
+
+ Privilege to delete rows from a specific table.
+
+
+
- >
- >
-
- >
- REVOKE { SELECT | DELETE | USAGE | ALL PRIVILEGES } [, ...]
- ON object>
- FROM { PUBLIC | username [, ...] } { RESTRICT | CASCADE }
- REVOKE { INSERT | UPDATE | REFERENCES } [, ...] [ ( column [, ...] ) ]
- ON object>
- FROM { PUBLIC | username [, ...] } { RESTRICT | CASCADE }
- >
-
- >
- Refer to the GRANT command for details on individual fields.
- >
- listitem>
- >
-
- >
- m>
- >
- REVOKE GRANT OPTION FOR privilege [, ...]
- ON object>
- FROM { PUBLIC | username [, ...] } { RESTRICT | CASCADE }
- >
-
-
- Rescinds authority for a user to grant the specified privilege to others.
- Refer to the GRANT command for details on individual fields.
- >
- listitem>
- >
-
+ >
+ >
+ RULE
+ >
+
+ Privilege to define rules on table/view.
+ (See CREATE RULE).
+ >
+
+ >
+
+ >
+ >
+ ALL
+ >
+ <listitem>
+ Rescind all privileges.
+ >
+ m>
+ >
+
+ >
+
+ object>
+
+
+ The name of an object from which to revoke access.
+ The possible objects are:
+ >
+ <listitem>
+ table
+
+
+
- The possible objects are:
-
- [ TABLE ] table/view
-
- CHARACTER SET character-set
-
- COLLATION collation
-
- TRANSLATION translation
-
- DOMAIN domain
-
-
+ view
- If user1 gives a privilege WITH GRANT OPTION to user2,
- and user2 gives it to user3 then user1 can revoke
- this privilege in cascade using the CASCADE keyword.
+
+
+
+ sequence
+
+
+
- If user1 gives a privilege WITH GRANT OPTION to user2,
- and user2 gives it to user3 then if user1 try revoke
- this privilege it fails if he/she specify the RESTRICT
- keyword.
+ index
-
-
-
+
+
+
+
+
+
+
+
+ group
+
+
+ The name of a group from whom to revoke privileges.
+
+
+
+
+
+
+ username
+
+
+ The name of a user from whom revoke privileges. Use the PUBLIC keyword
+ to specify all users.
+
+
+
+
+
+
+ PUBLIC
+
+
+ Rescind the specified privilege(s) for all users.
+
+
+
+
+
+
+
+
+
+ 1998-09-24
+
+
+ Outputs
+
+
+
+
+
+ CHANGE
+
+
+ Message returned if successfully.
+
+
+
+
+
+
+ ERROR
+
+
+ Message returned if object is not available or impossible
+ to revoke privileges from a group or users.
+
+
+
+
+
+
+
+
+
+
+ 1998-09-24
+
+
+ Description
+
+ REVOKE allows creator of an object to revoke permissions granted
+ before, from all users (via PUBLIC) or a certain user or group.
+
+
+
+
+ 1998-09-24
+
+
+ Notes
+
+ Refer to psql \z command for further information about permissions
+ on existing objects:
+
+Database = lusitania
++------------------+---------------------------------------------+
+| Relation | Grant/Revoke Permissions |
++------------------+---------------------------------------------+
+| mytable | {"=rw","miriam=arwR","group todos=rw"} |
++------------------+---------------------------------------------+
+Legend:
+ uname=arwR -- privileges granted to a user
+ group gname=arwR -- privileges granted to a GROUP
+ =arwR -- privileges granted to PUBLIC
+
+ r -- SELECT
+ w -- UPDATE/DELETE
+ 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;
+
+
+
+
+
+
+
+
+
+ Usage
+
+-- 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 ON kinds FROM manuel;
+
+
+
+
+
+
+ Compatibility
+
+
+
+
+ 1998-09-01
+
+
+ SQL92
+
+ The SQL92 syntax for REVOKE
+ has additional capabilities for rescinding
+ privileges, including those on individual columns in tables:
+
+
+
+
+
+REVOKE { SELECT | DELETE | USAGE | ALL PRIVILEGES } [, ...]
+ ON object
+ FROM { PUBLIC | username [, ...] } { RESTRICT | CASCADE }
+REVOKE { INSERT | UPDATE | REFERENCES } [, ...] [ ( column [, ...] ) ]
+ ON object
+ FROM { PUBLIC | username [, ...] } { RESTRICT | CASCADE }
+
+
+
+ Refer to GRANT for details on individual fields.
+
+
+
+
+
+
+
+REVOKE GRANT OPTION FOR privilege [, ...]
+ ON object
+ FROM { PUBLIC | username [, ...] } { RESTRICT | CASCADE }
+
+
+
+ Rescinds authority for a user to grant the specified privilege
+ to others.
+ Refer to the GRANT command for details
+ on individual fields.
+
+
+
+
+
+ The possible objects are:
+
+
+ [ TABLE ] table/view
+
+
+ CHARACTER SET character-set
+
+
+ COLLATION collation
+
+
+ TRANSLATION translation
+
+
+ DOMAIN domain
+
+
+
+
+ If user1 gives a privilege WITH GRANT OPTION to user2,
+ 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
+ this privilege it fails if he/she specify the RESTRICT
+ keyword.
+
+
+
+
+
+
-<REFENTRY ID="SQL-ROLLBACK">
->
->
+<refentry id="SQL-ROLLBACK">
+ >
+ >
ROLLBACK
->
-SQL - Language Statements>
->
->
->
+ >
+ SQL - Language Statements>
+ >
+ >
+ >
ROLLBACK
->
->
-Aborts the current transaction
->
-
->
->
-1998-09-24>
->
->
-ROLLBACK [ WORK ]
->
+ >
+ >
+ Aborts the current transaction
+ >
+
+ >
+ >
+ 1998-09-24>
+ >
+ >
+ROLLBACK [ WORK | TRANSACTION ]
+ >
- ="R2-SQL-ROLLBACK-1">
- >
- 1998-09-24>
- >
- >
- Inputs
- >
- None.
-
- 2>
+ ="R2-SQL-ROLLBACK-1">
+ >
+ 1998-09-24>
+ >
+ >
+ Inputs
+ >
+ None.
+
+ 2>
- ="R2-SQL-ROLLBACK-2">
- >
- 1998-09-24>
- >
- >
- Outputs
- >
-
- >
- >
- >
- ABORT
- >
- >
- Message returned if successful.
-
-
- >
-
- >
- >
- NOTICE: UserAbortTransactionBlock and not in in-progress state
- ABORT
- >
- >
- If there is not any transaction currently in progress.
-
-
- >
- >
-
- 2>
- >
+ ="R2-SQL-ROLLBACK-2">
+ >
+ 1998-09-24>
+ >
+ >
+ Outputs
+ >
+
+ >
+ >
+ >
+ ABORT
+ >
+ >
+ Message returned if successful.
+
+
+ >
+
+ >
+ >
+ NOTICE: UserAbortTransactionBlock and not in in-progress state
+ ABORT
+ >
+ >
+ If there is not any transaction currently in progress.
+
+
+ >
+ >
+
+ 2>
+ >
-
-
- 1998-09-24
-
-
- Description
-
- ROLLBACK rolls back the current transaction and causes
- all the updates made by the transaction to be discarded.
-
-
-
- 1998-09-24
-
-
- Notes
-
- The keyword WORK is noise and can be omitted.
-
- Use the COMMIT statement to successfully
- terminate a transaction.
-
-
-
+
+
+ 1998-09-24
+
+
+ Description
+
-
-
- Usage
-
- --To abort all changes:
- --
- ROLLBACK WORK;
-
-
-
-
-
-
- Compatibility
-
-
-
-
-
- 1998-09-24
-
-
- SQL92
-
- Full compatibility.
-
-
-
-
+ ROLLBACK rolls back the current transaction and causes
+ all the updates made by the transaction to be discarded.
+
+
+
+
+ 1998-09-24
+
+
+ Notes
+
+ The keywords WORK and TRANSACTION are noise and can be omitted.
+
+
+ Use
+ to successfully terminate a transaction.
+
+
+
+
+
+
+ Usage
+
+ --To abort all changes:
+ --
+ ROLLBACK WORK;
+
+
+
+
+
+
+ Compatibility
+
+
+
+
+
+ 1998-09-24
+
+
+ SQL92
+
+ Full compatibility. TRANSACTION is a
+
+
+
+
+
+
SELECT [ALL|DISTINCT [ON column] ]
- expression [ AS name ] [, ...]
+ expression [ AS
+ name ] [, ...]
[ INTO [TEMP] [TABLE] new_table ]
- [ FROM table [alias ] [, ...] ]
+ [ FROM table
+ [alias ] [, ...] ]
[ WHERE condition ]
[ GROUP BY column [, ...] ]
[ HAVING condition [, ...] ]
- [ { UNION [ALL] | INTERSECT | EXCEPT } select ]
+ [ { UNION [ALL] | INTERSECT | EXCEPT }
+ class="PARAMETER">select ]
[ ORDER BY column [ ASC | DESC ] [, ...] ]
[ FOR UPDATE [OF class_name...]]
[ LIMIT count [OFFSET|, count]]
- <VARLISTENTRY>
- <TERM>
+ <varlistentry>
+ <term>
TEMP
- TERM>
- <LISTITEM>
- <PARA>
+ term>
+ <listitem>
+ <para>
The table is created unique to this session, and is
automatically dropped on session exit.
- PARA>
- LISTITEM>
- VARLISTENTRY>
+ para>
+ listitem>
+ varlistentry>
DISTINCT will eliminate all duplicate rows from the
selection.
DISTINCT ON column will eliminate all duplicates in the specified column; this is
-equivalent to using GROUP BY column. ALL will return all candidate rows,
+equivalent to using
GROUP BY
+ class="PARAMETER">column. ALL will return all candidate rows,
including duplicates.
The optional WHERE condition has the general form:
-WHERE expr cond_op expr [ log_op ... ]
+WHERE
expr
+class="PARAMETER">ETER">ce
"PARreplaceable> [
+class="PARAMETER">log_op ... ]
where cond_op can be
-table_query UNION [ ALL ] table_query
+table_query UNION [ ALL ]
+table_query
[ ORDER BY column [ ASC | DESC ] [, ...] ]
-table_query INTERSECT table_query
+table_query INTERSECT
+table_query
[ ORDER BY column [ ASC | DESC ] [, ...] ]
-table_query EXCEPT table_query
+table_query EXCEPT
+ table_query
[ ORDER BY column [ ASC | DESC ] [, ...] ]
FROM distributors d, films f
WHERE f.did = d.did
- title |did|name | date_prod|kind
- -------------------------+---+----------------+----------+----------
- The Third Man |101|British Lion |1949-12-23|Drama
- The African Queen |101|British Lion |1951-08-11|Romantic
- Une Femme est une Femme |102|Jean Luc Godard |1961-03-12|Romantic
- Vertigo |103|Paramount |1958-11-14|Action
- Becket |103|Paramount |1964-02-03|Drama
- 48 Hrs |103|Paramount |1982-10-22|Action
- War and Peace |104|Mosfilm |1967-02-12|Drama
- West Side Story |105|United Artists |1961-01-03|Musical
- Bananas |105|United Artists |1971-07-13|Comedy
- Yojimbo |106|Toho |1961-06-16|Drama
- There's a Girl in my Soup|107|Columbia |1970-06-11|Comedy
- Taxi Driver |107|Columbia |1975-05-15|Action
- Absence of Malice |107|Columbia |1981-11-15|Action
- Storia di una donna |108|Westward |1970-08-15|Romantic
- The King and I |109|20th Century Fox|1956-08-11|Musical
- Das Boot |110|Bavaria Atelier |1981-11-11|Drama
- Bed Knobs and Broomsticks|111|Walt Disney | |Musical
+title |did|name | date_prod|kind
+-------------------------+---+----------------+----------+----------
+The Third Man |101|British Lion |1949-12-23|Drama
+The African Queen |101|British Lion |1951-08-11|Romantic
+Une Femme est une Femme |102|Jean Luc Godard |1961-03-12|Romantic
+Vertigo |103|Paramount |1958-11-14|Action
+Becket |103|Paramount |1964-02-03|Drama
+48 Hrs |103|Paramount |1982-10-22|Action
+War and Peace |104|Mosfilm |1967-02-12|Drama
+West Side Story |105|United Artists |1961-01-03|Musical
+Bananas |105|United Artists |1971-07-13|Comedy
+Yojimbo |106|Toho |1961-06-16|Drama
+There's a Girl in my Soup|107|Columbia |1970-06-11|Comedy
+Taxi Driver |107|Columbia |1975-05-15|Action
+Absence of Malice |107|Columbia |1981-11-15|Action
+Storia di una donna |108|Westward |1970-08-15|Romantic
+The King and I |109|20th Century Fox|1956-08-11|Musical
+Das Boot |110|Bavaria Atelier |1981-11-11|Drama
+Bed Knobs and Broomsticks|111|Walt Disney | |Musical
To sum the column len of all films and group
FROM actors
WHERE actors.name LIKE 'W%'
- name
- --------------
- Walt Disney
- Walter Matthau
- Warner Bros.
- Warren Beatty
- Westward
- Woody Allen
+name
+--------------
+Walt Disney
+Walter Matthau
+Warner Bros.
+Warren Beatty
+Westward
+Woody Allen
-
-
-
-SELECT INTO
-
- SQL - Language Statements
-
-
-
-SELECT INTO
-
-
-Create a new table from an existing table or view
-
-
-
- 1998-09-22
-
-
-SELECT [ ALL | DISTINCT ] expression [ AS name ] [, ...]
- INTO [TEMP] [ TABLE ] new_table ]
- [ FROM table [alias] [, ...] ]
- [ WHERE condition ]
- [ GROUP BY column [, ...] ]
- [ HAVING condition [, ...] ]
- [ { UNION [ALL] | INTERSECT | EXCEPT } select]
- [ ORDER BY column [ ASC | DESC ] [, ...] ]
- [ FOR UPDATE [OF class_name...]]
- [ LIMIT count [OFFSET|, count]]
-
-
-
-
- 1998-09-22
-
-
- Inputs
-
-All input fields are described in detail for SELECT.
-
-
-
-
-
- 1998-09-22
-
-
- Outputs
-
-All output fields are described in detail for SELECT.
-
-
-
-
-
-
- 1998-09-22
-
-
- Description
-
- SELECT INTO creates a new table from the results of a query. Typically, this
- query draws data from an existing table, but any SQL query is allowed.
-
- CREATE TABLE AS is functionally equivalent to the SELECT INTO command.
-
-
-
-
-
-
1998-09-24
-SET variable { TO | = } { 'value' | DEFAULT }
+SET variable { TO | = } {
+ 'value' | DEFAULT }
SET TIME ZONE { 'timezone' | LOCAL | DEFAULT };
SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZED }
-<REFENTRY ID="SQL-SHOW">
->
->
-SHOW
->
-SQL - Language Statements>
->
->
->
-SHOW
->
->
-Shows run-time parameters for session
->
-
->
->
-1998-09-24>
->
->
-SHOW <REPLACEABLE CLASS="PARAMETER">variable>
->
+<refentry id="SQL-SHOW">
+ >
+ >
+ SHOW
+ >
+ SQL - Language Statements>
+ >
+ >
+ >
+ SHOW
+ >
+ >
+ Shows run-time parameters for session
+ >
+
+ >
+ >
+ 1998-09-24>
+ >
+ >
+SHOW <replaceable class="PARAMETER">variable>
+ >
-
-
- 1998-09-24
-
-
- Inputs
-
-
-
-
-
- variable
-
-
- Refer to SET for more information on available
- variables.
-
-
-
-
-
-
+
+
+ 1998-09-24
+
+
+ Inputs
+
-
-
- 1998-09-24
-
-
- Outputs
-
-
-
-
-
- NOTICE: variable is value
- SHOW VARIABLE
-
-
- Message returned if successfully.
-
-
-
-
-
- NOTICE: Unrecognized variable value
-
-
- Message returned if value does not exist.
-
-
-
-
-
-
- NOTICE: Time zone is unknown
- SHOW VARIABLE
-
-
- If the TZ environment variable is not set.
-
-
-
-
-
-
-
+
+
+
+ variable
+
+
+ Refer to SET for more information on available
+ variables.
+
+
+
+
+
+
-
-
- 1998-09-24
-
-
- Description
-
- SHOW will display the current
- configuration parameters for
- variable during a session.
-
- The session can be configured using SET statement,
- and values
- can be restored to the defaults using RESET statement.
- Parameters and values are case-insensitive.
-
+
+
+ 1998-09-24
+
+
+ Outputs
+
-
-
- 1998-09-24
-
-
- Notes
-
- language extension.
-
- Refer to SET/RESET
- to set/reset variable values.
- See also SET TIME ZONE.
-
-
-
+
+
+
+
NOTICE:
+ class="PARAMETER">">variabE> is value
+ SHOW VARIABLE
+
+
+ Message returned if successfully.
+
+
+
+
+
+ NOTICE: Unrecognized variable value
+
+
+ Message returned if value does not exist.
+
+
+
+
+
+
+ NOTICE: Time zone is unknown
+ SHOW VARIABLE
+
+
+ If the TZ environment variable is not set.
+
+
+
+
+
+
+
-
-
- Usage
-
- -- show DateStyle;
- SHOW DateStyle;
- NOTICE:DateStyle is Postgres with US (NonEuropean) conventions
-
- -- show Geqo;
- SHOW GEQO;
- NOTICE:GEQO is ON
-
-
-
+
+
+ 1998-09-24
+
+
+ Description
+
+ SHOW will display the current
+ configuration parameters for
+ variable during a session.
+
+ The session can be configured using SET statement,
+ and values
+ can be restored to the defaults using RESET statement.
+ Parameters and values are case-insensitive.
+
-
-
- Compatibility
-
-
-
-
-
- 1998-09-24
-
-
- SQL92
-
- There is no
SET defined in
SQL92.
-
-
-
-
+
+
+ 1998-09-24
+
+
+ Notes
+
+ language extension.
+
+ Refer to SET/RESET
+ to set/reset variable values.
+ See also SET TIME ZONE.
+
+
+
+
+
+
+ Usage
+
+-- show DateStyle;
+SHOW DateStyle;
+NOTICE:DateStyle is Postgres with US (NonEuropean) conventions
+
+-- show Geqo;
+SHOW GEQO;
+NOTICE:GEQO is ON
+
+
+
+
+
+
+ Compatibility
+
+
+
+
+
+ 1998-09-24
+
+
+ SQL92
+
+ There is no
SHOW defined in
SQL92.
+
+
+
+
+
+