create_user.sgml 6.79 KB
Newer Older
1
<!--
2
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_user.sgml,v 1.13 2000/01/14 22:11:32 petere Exp $
3 4 5
Postgres documentation
-->

6 7
<refentry id="SQL-CREATEUSER">
 <refmeta>
8
  <refentrytitle id="sql-createuser-title">
9
   CREATE USER
10 11 12 13 14
  </refentrytitle>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>
 <refnamediv>
  <refname>
15
   CREATE USER
16 17
  </refname>
  <refpurpose>
18
   Creates a new database user
19
  </refpurpose>
20
 </refnamediv>
21 22
 <refsynopsisdiv>
  <refsynopsisdivinfo>
23
   <date>1999-07-20</date>
24 25
  </refsynopsisdivinfo>
  <synopsis>
Bruce Momjian's avatar
Bruce Momjian committed
26 27 28
CREATE USER <replaceable class="PARAMETER">username</replaceable>
    [ WITH
     [ SYSID <replaceable class="PARAMETER">uid</replaceable> ]
29
     [ PASSWORD '<replaceable class="PARAMETER">password</replaceable>' ] ]
30
    [ CREATEDB   | NOCREATEDB ] [ CREATEUSER | NOCREATEUSER ]
31 32 33
    [ IN GROUP     <replaceable class="PARAMETER">groupname</replaceable> [, ...] ]
    [ VALID UNTIL  '<replaceable class="PARAMETER">abstime</replaceable>' ]
  </synopsis>
34
  
35 36 37 38 39
  <refsect2 id="R2-SQL-CREATEUSER-1">
   <refsect2info>
    <date>1998-09-21</date>
   </refsect2info>
   <title>
40
    Inputs
41 42
   </title>
   <para>
43

44 45
    <variablelist>
     <varlistentry>
46
      <term><replaceable class="parameter">username</replaceable></term>
47 48 49 50 51 52 53
      <listitem>
       <para>
	The name of the user.
       </para>
      </listitem>
     </varlistentry>

Bruce Momjian's avatar
Bruce Momjian committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
     <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>
       <para>
        If this is not specified, the highest assigned user id plus one
        will be used as default.
       </para>
      </listitem>
     </varlistentry>

71
     <varlistentry>
72
      <term><replaceable class="parameter">password</replaceable></term>
73 74
      <listitem>
       <para>
75 76 77 78 79
        Sets the user's password. If you do not plan to use password
        authentication you can omit this option, otherwise the user
        won't be able to connect to a password-authenticated server.
        See pg_hba.conf(5) or the administrator's guide for details on
        how to set up authentication mechanisms.
80 81 82 83 84
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
85 86
      <term>CREATEDB</term>
      <term>NOCREATEDB</term>
87 88 89 90 91 92 93 94 95 96 97 98
      <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>
99 100
      <term>CREATEUSER</term>
      <term>NOCREATEUSER</term>
101 102 103
      <listitem>
       <para>
	These clauses determine whether a user will be permitted to
104 105
	create new users himself. This option will also make the user
        a superuser who can override all access restrictions.
106 107 108 109 110 111 112
	Omitting this clause will set the user's value of this
	attribute to be NOCREATEUSER.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
113
      <term><replaceable class="parameter">groupname</replaceable></term>
114 115 116 117 118 119 120 121
      <listitem>
       <para>
	A name of a group into which to insert the user as a new member.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
122
      <term><replaceable class="parameter">abstime</replaceable></term>
123 124 125
      <listitem>
       <para>
	The VALID UNTIL clause sets an absolute time after which the
126 127
	user's password is no longer valid. 
	If this clause is omitted the login will be valid for all time.
128 129 130
       </para>
      </listitem>
     </varlistentry>
131 132
    </variablelist>
   </para>
133
  </refsect2>
134
  
135 136 137 138 139
  <refsect2 id="R2-SQL-CREATEUSER-2">
   <refsect2info>
    <date>1998-09-21</date>
   </refsect2info>
   <title>
140
    Outputs
141 142 143 144 145
   </title>

   <para>
    <variablelist>
     <varlistentry>
146
      <term><computeroutput>CREATE USER</computeroutput></term>
147 148 149 150 151 152 153 154 155 156
      <listitem>
       <para>
	Message returned if the command completes successfully.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>
 </refsynopsisdiv>
157

158 159 160 161 162
 <refsect1 id="R1-SQL-CREATEUSER-1">
  <refsect1info>
   <date>1998-09-21</date>
  </refsect1info>
  <title>
163
   Description
164 165
  </title>
  <para>
166
   CREATE USER will add a new user to an instance of 
167 168 169
   <productname>PostgreSQL</productname>. Refer to the adminstrator's
   guide for information about managing users and authentication.
   You must be a database superuser to use this command.
170
  </para>
171 172 173 174 175 176 177 178 179 180 181 182
  <para>
   Use <xref linkend="SQL-ALTERUSER" endterm="SQL-ALTERUSER-title">
   to change a user's password and privileges, and <xref linkend="SQL-DROPUSER"
   endterm="SQL-DROPUSER-title"> to remove a user.
   Use <command>ALTER GROUP</command> to add or remove the user from other groups.
   <productname>PostgreSQL</productname>
   comes with a script <xref linkend="APP-CREATEUSER"
   endterm="APP-CREATEUSER-title">
   which has the same functionality as this command (in fact, it calls this command)
   but can be run from the command shell.
  </para>  
 </refsect1> 
183 184
 <refsect1 id="R1-SQL-CREATEUSER-2">
  <title>
185
   Usage
186 187
  </title>
  <para>
188
   Create a user with no password:
189
<programlisting>
190
CREATE USER jonathan
191
</programlisting>
192
  </para>
193

194
  <para>
195
   Create a user with a password:
196 197 198
<programlisting>
CREATE USER davide WITH PASSWORD 'jw8s0F4'
</programlisting>
199
  </para>
200

201 202 203 204
  <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:
205

206 207 208
<programlisting>
CREATE USER miriam WITH PASSWORD 'jw8s0F4' VALID UNTIL 'Jan 1 2002'
</programlisting>
209
  </para>
210

211 212
  <para> 
   Create an account where the user can create databases:
213 214 215
<programlisting>
CREATE USER manuel WITH PASSWORD 'jw8s0F4' CREATEDB
</programlisting>
216
  </para>
217
 </refsect1>
218
 
219 220
 <refsect1 id="R1-SQL-CREATEUSER-3">
  <title>
221
   Compatibility
222
  </title>
223
  
224 225 226 227 228
  <refsect2 id="R2-SQL-CREATEUSER-4">
   <refsect2info>
    <date>1998-09-21</date>
   </refsect2info>
   <title>
229
    SQL92
230
   </title>
231

232
   <para>
233
    There is no <command>CREATE USER</command> statement in SQL92.
234
   </para>
235 236
  </refsect2>
 </refsect1>
237
</refentry>
238 239 240 241

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
242
sgml-omittag:nil
243 244 245 246 247 248 249 250 251 252 253
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:
254
-->