PostgreSQL – How to Revoke Delete Permission from Table for Database Owner

permissionspostgresql

I am trying to revoke the DELETE privilege on a table for a database owner.

I execute the command:

REVOKE DELETE on my_table FROM database_owner;

But when querying this via

SELECT has_table_privilege('users','delete');

I get true returned and am able to continue deletion.

How can I revoke deletion from this table?

Thanks.

Best Answer

You cannot revoke privileges that are not granted.

The table (not database) owner implicitly has full rights on the table. They cannot be revoked, except by changing the owner of the table.

What you probably want to do is connect with a user other than the owner of the database/tables, and GRANT that user only the rights it should have over the table(s).