Drop User
Removes a PostgreSQL user.
Synopsis
DROP USER nameParameters
nameThe username of the PostgreSQL user you wish to remove.
Results
DROP USERThe message returned when a PostgreSQL user is successfully removed.
ERROR: DROP USER: user "name" does not existThe error returned if the specified PostgreSQL user cannot be found on the connected host.
ERROR: DROP USER: user "name" owns database "database", cannot be removedThe error returned if a database called
databasestill exists when you attempt to drop thenameuser. 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;
DROPBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access