DROP USER
Removes a name from the list of authorized database users.
Syntax
DROP USER name[,…] [ CASCADE ]
Parameters
name |
Specifies the name or names of the user to drop. |
CASCADE |
[Optional] 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
Must be a superuser to drop a user.
Examples
DROP USER <username>
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 <name> 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;
Caution: Tables owned by the user being dropped cannot be recovered after you issue DROP USER CASCADE
.
DROP USER
<username> 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