1
votes

Someone created a database and I am a super user in PG Admin. When I tried to access the database tables by clicking on it, I received the error message "permission denied for relation table_name". It's a table for the Mayan database. I tried all kinds of methods, but I am unfamiliar with this and not sure how to go about doing it. I opened the SQL editor and entered the GRANT commands to grant myself access, but I keep getting "permission denied". I am using PG Admin.

Can anyone tell me how can I be granted access to the table?

1
Can you share what GRANT commands you have tried? - dave_slash_null
Removed angle brackets around "table_name" because SO does not render them inline unless it is code. Improved grammar. - Steve Piercy
maybe I am doing it wrongly, im not sure. I opened PG Admin, clicked on the database, on the tool bar I selected the SQL icon where I can enter SQL statements, and entered this: "GRANT ALL PRIVILEGES ON DATABASE mayan TO myuser". It responded saying no priviledges were granted for "mayan". - Cherple

1 Answers

1
votes

To access a table you have to grant privileges to the tables with GRANT. First enter to the database and open a SQL editor then execute one of the next queries:

-- For all privileges
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO user

-- For viewing privileges
GRANT SELECT ON ALL TABLES IN SCHEMA public TO user

Note that you have to specify the schema.