dropuser
PostgreSQL user removal utility
TLDR
SYNOPSIS
dropuser [options] username
DESCRIPTION
dropuser removes a PostgreSQL role. It is a thin wrapper around the `DROP ROLE` SQL statement, provided so that user management can be scripted from the shell without invoking `psql`.In PostgreSQL, users and groups are the same thing: a role. `dropuser` and `createuser` are historical names kept for familiarity, and the distinction between a "user" and a "role" is only whether the role has the LOGIN attribute.To run it you must be a superuser, or hold CREATEROLE and have been granted membership in the role you are dropping.
PARAMETERS
USERNAME
PostgreSQL role/user to drop.-h, --host HOST
Server hostname.-p, --port PORT
Server port.-U, --username USER
Connect as this user.-i, --interactive
Prompt for confirmation before dropping.--if-exists
Do not raise an error if the role does not exist.-e, --echo
Print the SQL command that is being sent to the server.-w, --no-password
Never prompt for a password. Useful in scripts, where the password must come from `~/.pgpass` or the environment.-W, --password
Force a password prompt.--maintenance-db=dbname
Database to connect to in order to issue the command. Defaults to `postgres`.-V, --version
Print the version and exit.--help
Display help information.
INSTALL
CAVEATS
A role cannot be dropped while it still owns anything. PostgreSQL refuses with a dependency error listing the objects, and the fix is to reassign or remove them first:
HISTORY
dropuser is one of PostgreSQL's original client wrapper scripts, dating from a time when they really were shell scripts around `psql`; they are C programs now, but the interface is unchanged. The name predates the unification of users and groups into roles in PostgreSQL 8.1 (2005), which is why the tool is called `dropuser` while the SQL it emits says `DROP ROLE`.
SEE ALSO
createuser(1), psql(1), dropdb(1), createdb(1)
