PostgreSQL Permissions – How to Allow User to Drop Some Tables

permissionspostgresqlpostgresql-9.3

Is there a way to have a PostgreSQL user that can drop all but specified tables?

We need the user to be able to drop some tables but not all. It would be preferred to be able to use something like revoke where we could specify which tables the user should not be able to drop.

Best Answer

Since you're running 9.3, you could potentially use an event trigger to catch the tag DROP TABLE and prevent that for certain users.

Denish Patel has a example in his blog post here Preventing Human Errors in Postgres. Search for the string "Function to prevent single table drop". That should give you enough of a start to modify for your specific needs.