DROP USER
Removes a name from the list of authorized database users.
Syntax
DROP USER [ IF EXISTS ] user‑name[,…] [ CASCADE ]
Parameters
IF EXISTS
|
Specifies not to report an error if the users to drop do not exist. Use this clause in SQL scripts to avoid errors on dropping non-existent objects before attempting to create them. |
user‑name |
The name of a user to drop. |
CASCADE |
Drops all user-defined objects created by the user dropped, including schema, table and all views that reference the table, and the table's associated projections. |
Privileges
Superuser
Examples
DROP USER
fails if objects exist that were created by the user, such as schemas, and tables and their associated projections:
=> DROP USER user1; NOTICE: Table T_tbd1 depends on User user1 ROLLBACK: DROP failed due to dependencies DETAIL: Cannot drop User user1 because other objects depend on it HINT: Use DROP ... CASCADE to drop the dependent objects too
DROP USER CASCADE
succeeds regardless of any pre-existing user-defined objects. The statement forcibly drops all user-defined objects, such as schemas, tables and their associated projections:
=> DROP USER user1 CASCADE;
Tables owned by the user being dropped cannot be recovered after you issue DROP USER CASCADE
.
DROP USER
succeeds if no user-defined objects exist (no schemas, tables or projections defined by the user):
=> CREATE USER user2; CREATE USER => DROP USER user2; DROP USER