Search code examples
postgresqlrolesprivileges

Postgresql role with no drop table permision


Is it possible to set role with access to one database, with all privileges except to drop tables?


Solution

  • Not really. If a user can issue CREATE TABLE, it can issue a DROP for that table as well. From the docs:

    The right to drop an object, or to alter its definition in any way, is not treated as a grantable privilege; it is inherent in the owner, and cannot be granted or revoked.

    And as noted by the CREATE TABLE docs:

    The table will be owned by the user issuing the command.

    There is no mechanism to allow a user to create tables that they do not own and therefore cannot drop.