I have the following postgres users which I can view by invoking the \du command in the terminal as follows:
postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------+----------- postgres | Superuser, Create role, Create DB, Replication | {} tutorial1 | | {}
According to the postgres documentation, I should be able to drop the user called "tutorial1" by entering the following command:
postgres=# DROP USER tutorial1
However, when I use that command nothing happens. The documentation doesn't provide any hints as to why this isn't working, nor does it provide clear examples.
That being said-- what is the command to drop this user?
To delete a Postgres role, run the following command in the PSQL client: DROP ROLE [IF EXISTS] <name>; The DROP USER statement is an alias for DROP ROLE . The Postgres users are roles with LOGIN permissions.
PostgreSQL will use this mode to insert each row's index entry. The access method must allow duplicate entries into the index, and report any potential duplicates by returning false from aminsert . For each row for which false is returned, a deferred recheck will be scheduled.
I've wasted way too much time on trying to find all the things to unwind. In addition to the above (or possibly as a complete replacement), refer to this answer to a similar question: https://stackoverflow.com/a/11750309/647581
DROP OWNED BY your_user; DROP USER your_user;
did the trick for me
If you find yourself here (like me) because you are unable to drop the user, the following template may be helpful:
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM tutorial1; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM tutorial1; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM tutorial1; DROP USER tutorial1;
The user may have privileges in other schemas, in which case you will have to run the appropriate REVOKE line with "public" replaced by the correct schema. To show all of the schemas and privilege types for a user, I edited the \dp command to make this query:
SELECT n.nspname as "Schema", CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'S' THEN 'sequence' WHEN 'f' THEN 'foreign table' END as "Type" FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE pg_catalog.array_to_string(c.relacl, E'\n') LIKE '%postgres%';
I'm not sure which privilege types correspond to revoking on TABLES, SEQUENCES, or FUNCTIONS, but I think all of them fall under one of the three.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With