Drop User

Removes a PostgreSQL user.

Synopsis

DROP USER name

Parameters

name

The username of the PostgreSQL user you wish to remove.

Results

DROP USER

The message returned when a PostgreSQL user is successfully removed.

ERROR: DROP USER: user "name" does not exist

The error returned if the specified PostgreSQL user cannot be found on the connected host.

ERROR: DROP USER: user "name" owns database "database", cannot be removed

The error returned if a database called database still exists when you attempt to drop the name user. Any owned databases must first be removed.

Description

Use the DROP USER command to remove a user from a database. You are not allowed to remove a user that owns a database. All database objects the user owned will continue to exist within the database.

Note

Description

To run this command from the command prompt, use dropuser, which is a wrapper application to the same SQL command (see Chapter 10 for more about this command).

Example

The following example permanently drops the PostgreSQL user named jonathan from the system:

template1=# DROP USER jonathan;
DROP

Get Practical PostgreSQL now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.