Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > by-pkgid > db7d48fed1469a51f3fb965d5b5b2ac1 > files > 482

postgresql-docs-7.4.1-2.5.100mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>CREATE USER</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 7.4.1 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SQL Commands"
HREF="sql-commands.html"><LINK
REL="PREVIOUS"
TITLE="CREATE TYPE"
HREF="sql-createtype.html"><LINK
REL="NEXT"
TITLE="CREATE VIEW"
HREF="sql-createview.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
NAME="creation"
CONTENT="2003-12-22T03:48:47"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 7.4.1 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-createtype.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-createtype.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-createview.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-createview.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="SQL-CREATEUSER"
></A
>CREATE USER</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN38912"
></A
><H2
>Name</H2
>CREATE USER&nbsp;--&nbsp;define a new database user account</DIV
><A
NAME="AEN38915"
></A
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN38917"
></A
><H2
>Synopsis</H2
><PRE
CLASS="SYNOPSIS"
>CREATE USER <VAR
CLASS="REPLACEABLE"
>name</VAR
> [ [ WITH ] <VAR
CLASS="REPLACEABLE"
>option</VAR
> [ ... ] ]

where <VAR
CLASS="REPLACEABLE"
>option</VAR
> can be:
    
      SYSID <VAR
CLASS="REPLACEABLE"
>uid</VAR
> 
    | [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<VAR
CLASS="REPLACEABLE"
>password</VAR
>'
    | CREATEDB | NOCREATEDB
    | CREATEUSER | NOCREATEUSER
    | IN GROUP <VAR
CLASS="REPLACEABLE"
>groupname</VAR
> [, ...]
    | VALID UNTIL '<VAR
CLASS="REPLACEABLE"
>abstime</VAR
>' </PRE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN38926"
></A
><H2
>Description</H2
><P
>   <TT
CLASS="COMMAND"
>CREATE USER</TT
> adds a new user to a
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> database cluster.  Refer to
   <A
HREF="user-manag.html"
>Chapter 17</A
> and <A
HREF="client-authentication.html"
>Chapter 19</A
> for information about managing
   users and authentication.  You must be a database superuser to use
   this command.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN38933"
></A
><H2
>Parameters</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><VAR
CLASS="REPLACEABLE"
>name</VAR
></DT
><DD
><P
>	The name of the user.
       </P
></DD
><DT
><VAR
CLASS="REPLACEABLE"
>uid</VAR
></DT
><DD
><P
>        The <TT
CLASS="LITERAL"
>SYSID</TT
> clause can be used to choose the
        <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> user ID of the user that
        is being created. This is not normally not necessary, but may
        be useful if you need to recreate the owner of an orphaned
        object.
       </P
><P
>        If this is not specified, the highest assigned user ID plus one
	(with a minimum of 100) will be used as default.
       </P
></DD
><DT
><VAR
CLASS="REPLACEABLE"
>password</VAR
></DT
><DD
><P
>        Sets the user's password. If you do not plan to use password
        authentication you can omit this option, but then the user
        won't be able to connect if you decide to switch to password
        authentication.  The password can be set or changed later,
        using <A
HREF="sql-alteruser.html"
><I
>ALTER USER</I
></A
>.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>ENCRYPTED</TT
><BR><TT
CLASS="LITERAL"
>UNENCRYPTED</TT
></DT
><DD
><P
>	These key words control whether the password is stored
	encrypted in the system catalogs.  (If neither is specified,
	the default behavior is determined by the configuration
	parameter <VAR
CLASS="VARNAME"
>PASSWORD_ENCRYPTION</VAR
>.)  If the
	presented password string is already in MD5-encrypted format,
	then it is stored encrypted as-is, regardless of whether
	<TT
CLASS="LITERAL"
>ENCRYPTED</TT
> or <TT
CLASS="LITERAL"
>UNENCRYPTED</TT
> is specified
	(since the system cannot decrypt the specified encrypted
	password string).  This allows reloading of encrypted
	passwords during dump/restore.
       </P
><P
>        Note that older clients may lack support for the MD5
        authentication mechanism that is needed to work with passwords
        that are stored encrypted.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>CREATEDB</TT
><BR><TT
CLASS="LITERAL"
>NOCREATEDB</TT
></DT
><DD
><P
>	These clauses define a user's ability to create databases.  If
	<TT
CLASS="LITERAL"
>CREATEDB</TT
> is specified, the user being
	defined will be allowed to create his own databases. Using
	<TT
CLASS="LITERAL"
>NOCREATEDB</TT
> will deny a user the ability to
	create databases. If this clause is omitted,
	<TT
CLASS="LITERAL"
>NOCREATEDB</TT
> is used by default.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>CREATEUSER</TT
><BR><TT
CLASS="LITERAL"
>NOCREATEUSER</TT
></DT
><DD
><P
>	These clauses determine whether a user will be permitted to
	create new users himself. This option will also make the user
	a superuser who can override all access restrictions.
	Omitting this clause will set the user's value of this
	attribute to be <TT
CLASS="LITERAL"
>NOCREATEUSER</TT
>.
       </P
></DD
><DT
><VAR
CLASS="REPLACEABLE"
>groupname</VAR
></DT
><DD
><P
>	A name of a group into which to insert the user as a new member.
	Multiple group names may be listed.
       </P
></DD
><DT
><VAR
CLASS="REPLACEABLE"
>abstime</VAR
></DT
><DD
><P
>	The <TT
CLASS="LITERAL"
>VALID UNTIL</TT
> clause sets an absolute
	time after which the user's password is no longer valid.  If
	this clause is omitted the login will be valid for all time.
       </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN38995"
></A
><H2
>Notes</H2
><P
>   Use <A
HREF="sql-alteruser.html"
><I
>ALTER USER</I
></A
> to
   change the attributes of a user, and <A
HREF="sql-dropuser.html"
><I
>DROP USER</I
></A
> to remove a user.  Use <A
HREF="sql-altergroup.html"
><I
>ALTER GROUP</I
></A
> to add the
   user to groups or remove the user from groups.
  </P
><P
>   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> includes a program <A
HREF="app-createuser.html"
><I
><I
>createuser</I
></I
></A
> that has
   the same functionality as <TT
CLASS="COMMAND"
>CREATE USER</TT
> (in fact, it calls this
   command) but can be run from the command shell.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN39005"
></A
><H2
>Examples</H2
><P
>   Create a user with no password:
</P><PRE
CLASS="PROGRAMLISTING"
>CREATE USER jonathan;</PRE
><P>
  </P
><P
>   Create a user with a password:
</P><PRE
CLASS="PROGRAMLISTING"
>CREATE USER davide WITH PASSWORD 'jw8s0F4';</PRE
><P>
  </P
><P
>   Create a user with a password that is valid until the end of 2004.
   After one second has ticked in 2005, the password is no longer
   valid.

</P><PRE
CLASS="PROGRAMLISTING"
>CREATE USER miriam WITH PASSWORD 'jw8s0F4' VALID UNTIL '2005-01-01';</PRE
><P>
  </P
><P
> 
   Create an account where the user can create databases:
</P><PRE
CLASS="PROGRAMLISTING"
>CREATE USER manuel WITH PASSWORD 'jw8s0F4' CREATEDB;</PRE
><P>
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN39015"
></A
><H2
>Compatibility</H2
><P
>   The <TT
CLASS="COMMAND"
>CREATE USER</TT
> statement is a
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> extension.  The SQL standard
   leaves the definition of users to the implementation.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN39020"
></A
><H2
>See Also</H2
><A
HREF="sql-alteruser.html"
><I
>ALTER USER</I
></A
>, <A
HREF="sql-dropuser.html"
><I
>DROP USER</I
></A
>, <A
HREF="app-createuser.html"
><SPAN
CLASS="APPLICATION"
>createuser</SPAN
></A
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-createtype.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-createview.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>CREATE TYPE</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="sql-commands.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>CREATE VIEW</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>