Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Databases - Practical PostgreSQL
Previous Page Home Next Page

CREATE USER

Name

CREATE USER -- Creates a new PostgreSQL database user.

Synopsis

CREATE USER 
username

    [ WITH
      [ SYSID 
uid
 ]
      [ PASSWORD '
password
' ] ]
    [ CREATEDB | NOCREATEDB ] [ CREATEUSER | NOCREATEUSER ]
    [ IN GROUP 
groupname
 [, ...] ]
    [ VALID UNTIL  '
abstime
' ]

Parameters

username

The name of the new user you intend to create.

uid

The explicit user ID for the PostgreSQL user that you are creating; if left out of the CREATE USER command, the user ID will be automatically assigned.

password

The new PostgreSQL user's password; if the database is setup to require password authentication, this must be set for the user to be able to connect. Otherwise, a defined password is not meaningful to PostgreSQL.

CREATEDB | NOCREATEDB

The privilege to create new databases. Use CREATEDB, to give the user permission to create databases. Use NOCREATEDB to explicitly deny that permission (which is the default).

CREATEUSER | NOCREATEUSER

The superuser privilege. The use of CREATEUSER allows access to both the CREATE USER and DROP USER commands, as well as makes the user a superuser (with universal rights across all databases). NOCREATEUSER is the default.

groupname

The optional name of a group to which the user is to automatically be added.

abstime

The timestamp that defines when a user's password expires. When the date and time that abstime defines has been reached, the user's defined password becomes invalid. If unset, the password never expires.

Results

CREATE USER

The message returned when a user is created successfully.

Description

Use CREATE USER to add new users to a PostgreSQL database. This command is only usable by database superusers. For more information about managing users and authentication, refer to Chapter 10.

Note: You may also use the createuser script to add users to a database from the operating system command line. Use of the script is essentially as using this command.

Example

The following example demonstrates how to create a PostgreSQL user (david) in the accounting group that is valid until January 1, 2005 and has the specified password of jw8s0F4.

booktown=# 
CREATE USER david

booktown-# 
            WITH PASSWORD 'jw8s0F4' CREATEDB

booktown-# 
            IN GROUP accounting VALID UNTIL 'Jan 1 2005';

CREATE USER
Databases - Practical PostgreSQL
Previous Page Home Next Page

 
 
  Published under the terms of the Open Publication License Design by Interspire