How to correctly remove all DBMS users, of course, without postgres ? Only comes to mind

 delete * from pg_authid where rolname <> 'postgres' 

but incorrectly - something like a cascade is missing; in this case, no errors are displayed if there are related objects (for example, the user is the owner of the database).

  • Do not change the system tables. Get a list of users and generate the required drop users (or whatever they are removed in the post-post) - Mike

1 answer 1

 do $$ declare rname text; begin for rname in select rolname from pg_roles where rolname <> 'postgres' loop execute 'DROP ROLE ' || quote_ident(rname); end loop; end $$;