May 2018
Intermediate to advanced
576 pages
30h 25m
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