CREATE USER username [ WITH [ SYSID uid ] [ PASSWORD 'password' ] ] [ CREATEDB | NOCREATEDB ] [ CREATEUSER | NOCREATEUSER ] [ IN GROUP groupname [, ...] ] [ VALID UNTIL 'abstime' ]
This parameter takes the name of the new user you wish to create.
Use this option to explicitly state the PostgreSQL user ID for the user account that you are creating; if left out of the CREATE USER command, the user ID will be automatically assigned.
Use this parameter to define the user's password; if the database is setup to require password authentication, then this will need to be set. Otherwise, whether or not a user is created with a password is optional.
Use these keywords to determine whether or not the new user will have permissions to create databases. (Obviously, if this is set to CREATEDB, the user will be allowed to create databases. Otherwise, he will not. By default, users are set to NOCREATEDB.
Use these keywords to allow or disallow access to the CREATE USER and DROP USER commands. By default, users are set to NOCREATEUSER.
This parameter holds the name of the group you wish this user to be a member of.
By setting this parameter, you are specifying the aaccount will only be valid until the time specified. When it reaches that date, the user's password will become invalid.
Use CREATE USER to add new users to a specified PostgreSQL database. This command is only usable by database superusers. For more information about managing users and authentication, refer to Part 3, "Administrating PostgreSQL."
|The createuser Command|
You may also use the installed createuser script to add users to a database from the command line. It is essentially the same as using this command.
The following example demonstrates how to create a user account (david) in the accounting group that is valid until January 1, 2005 and has the specific password 'jw8s0F4.'
booktown=# CREATE USER david IN accounting VALID UNTIL 'Jan 1 2005' booktown=# WITH PASSWORD 'jw8s0F4' CREATEDB;