PostgreSQL Permissions – Fix Permission Denied Error When Deleting

permissionspostgresql

I recently had this issue where I created a database user and gave delete and update permission. Yet, I was getting permission denied on a delete query.

Create user: create user username password 'whatever';

Grant: grant update, delete on table to username;

Query which gave permission denied:

delete from table
where condition1 and
condition2 and
condition3

Best Answer

After a bit of hunting I realized that maybe I am getting this error because I am adding a condition to delete. Which means the database is probably selecting those records. And I hadn't granted select on the table to the user.

Grant select: grant select on table to username

And it worked.