dropuser
A core utility for removing a database user
dropuser
is a core utility for dropping (removing) a database user, and is essentially a wrapper around the DROP ROLE command.
dropuser
was added in PostgreSQL 7.0.
Usage
dropuser
does not emit any output on successful removal of a user.
Source code
The dropuser
source code is located at src/bin/scripts/dropuser.c.
Change history
- PostgreSQL 9.2
- option
--if-exists
added (commit 7fe33a51)
- option
- PostgreSQL 8.4
-w
/--no-password
option added (commit 9de59fd1)
- PostgreSQL 8.3
--quiet
option removed (commit 9539e64b)
- PostgreSQL 7.4
- converted from a shell script into a C program (commit 9e0ab712)
- PostgreSQL 7.3
- support for identifiers containing spaces added (commit 5804a7ce)
- PostgreSQL 7.0
- added (commit 240e4c98)
Examples
Basic usage example for dropuser
:
postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- admin | Cannot login | {newuser} newuser | | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} postgres=# \q postgres$ dropuser -h localhost newuser psql (14.3) Type "help" for help. postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- admin | Cannot login | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
References
- PostgreSQL documentation: dropuser