thank_you
thank_you

Reputation: 11107

Drop Role Not Dropping Though Role Name Exists

I have two users Jason and postgres. Since I just started learning this, I have no idea why this code is not working. All I'm trying to do is drop an user, but am unable too. What's wrong with my code?

postgres=# DROP OWNED BY Jason;
ERROR:  role "jason" does not exist
postgres=# \du
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 Jason     | Superuser, Create role, Create DB, Replication | {}
 postgres  | Superuser, Create role, Create DB, Replication | {}

Upvotes: 3

Views: 3425

Answers (2)

thar45
thar45

Reputation: 3560

You should follow couple of things while remove the user

First ,Should check and remove the database which are owned by the user

 DROP OWNED By "Jason" ;    // remove database objects owned by a database role 

Next can drop the role of the user by

 DROP ROLE "Jason";

Upvotes: 2

Craig Ringer
Craig Ringer

Reputation: 324711

Case sensitivity.

DROP OWNED BY "Jason";

PostgreSQL is case sensitive, it just lower-cases unquoted identifiers. To preserve case, "double quote" identifiers.

Upvotes: 14

Related Questions