May 2019
Intermediate to advanced
600 pages
20h 46m
English
The easiest solution to this problem is to refrain from dropping the user and use the trick from a previous recipe to prevent the user from connecting:
pguser=# alter user bob nologin;ALTER ROLE
This has the added benefit of the original owner of the table being available later, if needed, for auditing or debugging purposes (Why is this table here? Who created it?).
Then, you can assign the rights of the deleted user to a new user, using the following code:
pguser=# GRANT bob TO bobs_replacement;GRANT
Read now
Unlock full access