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 thename
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
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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.