[Amazon](500310) Invalid operation: permission denied for relation

You might encounter the below error while accessing a database object in Redshift database.

Error : [Amazon](500310) Invalid operation: permission denied for relation <your_object_name>

The issue here is that you do not have privileges granted on the database object <your_object_name> to your user account.

You should grant the required privileges on the database object to the user to resolve the error.

If your database object is a table, and the user is trying to select from the table, run the below grant statement(as a super user or schema owner):

grant select on <your_table_name> to <username>;
or
grant select on <your_table_name> to group <groupname>; (If your user is part of a group and you would like to grant access to the entire group)

You can also grant insert, update, delete or ALL privileges on the table to the user/group as required. It is a best practice to always grant minimum required privileges on the database objects to users.

If your database object is a function, run the below grant statement:

grant execute on function func_name(a integer, b varchar) to <username>;
See also  How to add multiple columns to a table in Redshift