postgresql/doc/src/sgml/ref/create_user.sgml

314 lines
8.1 KiB
Plaintext
Raw Normal View History

<!--
1999-12-04 06:03:49 +01:00
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_user.sgml,v 1.12 1999/12/04 05:03:49 momjian Exp $
Postgres documentation
-->
<refentry id="SQL-CREATEUSER">
<refmeta>
<refentrytitle id="sql-createuser-title">
1998-09-01 17:53:09 +02:00
CREATE USER
</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
1998-09-01 17:53:09 +02:00
CREATE USER
</refname>
<refpurpose>
1998-09-01 17:53:09 +02:00
Creates account information for a new user
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>1999-07-20</date>
</refsynopsisdivinfo>
<synopsis>
CREATE USER <replaceable class="PARAMETER">username</replaceable>
[ WITH
[ SYSID <replaceable class="PARAMETER">uid</replaceable> ]
[ PASSWORD <replaceable class="PARAMETER">password</replaceable> ] ]
[ CREATEDB | NOCREATEDB ] [ CREATEUSER | NOCREATEUSER ]
[ IN GROUP <replaceable class="PARAMETER">groupname</replaceable> [, ...] ]
[ VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>' ]
</synopsis>
1998-09-01 17:53:09 +02:00
<refsect2 id="R2-SQL-CREATEUSER-1">
<refsect2info>
<date>1998-09-21</date>
</refsect2info>
<title>
1998-09-01 17:53:09 +02:00
Inputs
</title>
<para>
<variablelist>
<varlistentry>
<term><replaceable class="parameter">username</replaceable></term>
<listitem>
<para>
The name of the user.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">uid</replaceable></term>
<listitem>
<para>
The <literal>SYSID</literal> clause can be used to choose
the <productname>PostgreSQL</productname> user id of the user
that is being created. It is not at all necessary that those
match the <acronym>UNIX</acronym> user ids, but some people
choose to keep the numbers the same.
</para>
1999-12-04 06:03:49 +01:00
<para>
If you still want the
OS user id and the <filename>usesysid</filename> to match
for any given user,
use the <application>createuser</application> script provided with
the <productname>Postgres</productname> distribution.
</para>
<para>
If this is not specified, the highest assigned user id plus one
will be used as default.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">password</replaceable></term>
<listitem>
<para>
The PASSWORD clause sets the user's password within
the "<filename>pg_shadow</filename>" table. For this reason,
<filename>"pg_shadow</filename>" is no
longer accessible to the instance of
<productname>Postgres</productname> that the
<productname>Postgres</productname>
user's password is initially set to NULL.
</para>
<para>
When a
user's password in the "<filename>pg_shadow</filename>"
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 <productname>Postgres</productname>
instance, and the password
stored in the "<filename>pg_shadow</filename>" 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.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>CREATEDB</term>
<term>NOCREATEDB</term>
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>CREATEUSER</term>
<term>NOCREATEUSER</term>
<listitem>
<para>
These clauses determine whether a user will be permitted to
create new
users in an instance of <productname>Postgres</productname>.
Omitting this clause will set the user's value of this
attribute to be NOCREATEUSER.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">groupname</replaceable></term>
<listitem>
<para>
A name of a group into which to insert the user as a new member.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">abstime</replaceable></term>
<listitem>
<para>
The VALID UNTIL clause sets an absolute time after which the
user's <productname>Postgres</productname>
login is no longer valid. Please note that
if a user does not have a password defined in the
"<filename>pg_shadow</filename>"
table, the valid until date will not be checked
during user authentication. If this clause is omitted,
a NULL value is stored in "<filename>pg_shadow</filename>"
for this attribute,
and the login will be valid for all time.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
1998-09-01 17:53:09 +02:00
<refsect2 id="R2-SQL-CREATEUSER-2">
<refsect2info>
<date>1998-09-21</date>
</refsect2info>
<title>
1998-09-01 17:53:09 +02:00
Outputs
</title>
<para>
<variablelist>
<varlistentry>
<term><computeroutput>
CREATE USER
</computeroutput></term>
<listitem>
<para>
Message returned if the command completes successfully.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-SQL-CREATEUSER-1">
<refsect1info>
<date>1998-09-21</date>
</refsect1info>
<title>
1998-09-01 17:53:09 +02:00
Description
</title>
<para>
1998-09-22 17:48:03 +02:00
CREATE USER will add a new user to an instance of
<productname>PostgreSQL</productname>.
</para>
<refsect2 id="R2-SQL-CREATEUSER-3">
<refsect2info>
<date>1998-09-21</date>
</refsect2info>
<title>
1998-09-01 17:53:09 +02:00
Notes
</title>
<para>
<command>CREATE USER</command> statement is a
<productname>Postgres</productname> language extension.
</para>
1998-09-01 17:53:09 +02:00
<para>
Use <command>DROP USER</command> or <command>ALTER USER</command>
statements to remove or modify a user account.
</para>
1998-09-01 17:53:09 +02:00
<para>
Refer to the <filename>pg_shadow</filename> table for further information.
</para>
<programlisting>
Table "pg_shadow"
Attribute | Type | Extra
-------------+---------+-------
usename | name |
usesysid | int4 |
usecreatedb | bool |
usetrace | bool |
usesuper | bool |
usecatupd | bool |
passwd | text |
valuntil | abstime |
1998-09-01 17:53:09 +02:00
</programlisting>
</refsect2>
</refsect1>
1998-09-01 17:53:09 +02:00
<refsect1 id="R1-SQL-CREATEUSER-2">
<title>
1998-09-01 17:53:09 +02:00
Usage
</title>
<para>
1998-09-01 17:53:09 +02:00
Create a user with no password:
<programlisting>
CREATE USER jonathan
</programlisting>
</para>
<para>
1998-09-01 17:53:09 +02:00
Create a user with a password:
<programlisting>
1999-10-07 18:40:36 +02:00
CREATE USER davide WITH PASSWORD "jw8s0F4"
</programlisting>
</para>
1998-09-01 17:53:09 +02:00
<para>
Create a user with a password, whose account is valid until the end of 2001.
Note that after one second has ticked in 2002, the account is not
valid:
<programlisting>
1999-10-07 18:40:36 +02:00
CREATE USER miriam WITH PASSWORD "jw8s0F4" VALID UNTIL 'Jan 1 2002'
</programlisting>
1998-09-01 17:53:09 +02:00
</para>
1998-09-01 17:53:09 +02:00
<para>
Create an account where the user can create databases:
<programlisting>
1999-10-07 18:40:36 +02:00
CREATE USER manuel WITH PASSWORD "jw8s0F4" CREATEDB
</programlisting>
1998-09-01 17:53:09 +02:00
</para>
</refsect1>
1998-09-01 17:53:09 +02:00
<refsect1 id="R1-SQL-CREATEUSER-3">
<title>
1998-09-01 17:53:09 +02:00
Compatibility
</title>
1998-09-01 17:53:09 +02:00
<refsect2 id="R2-SQL-CREATEUSER-4">
<refsect2info>
<date>1998-09-21</date>
</refsect2info>
<title>
1998-09-01 17:53:09 +02:00
SQL92
</title>
<para>
There is no <command>CREATE USER</command> statement in SQL92.
</para>
</refsect2>
</refsect1>
</refentry>
1998-09-01 17:53:09 +02:00
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
1998-09-01 17:53:09 +02:00
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->