Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7898835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:32:34+00:00 2026-06-03T08:32:34+00:00

How do you grant read/select access on all functions and views to an arbitrary

  • 0

How do you grant read/select access on all functions and views to an arbitrary user?

I use psql --user=postgres -d mydb -f myview.sql to create several functions and views, and then I run:

GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;

Having been granted all privileges, I would expect myuser to now have access to the functions and views created by the postgres user. However, when I try and access them with myuser, I get a “permission denied for relation…” error. Why is this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:32:36+00:00Added an answer on June 3, 2026 at 8:32 am

    The reason is that you need additional privileges to access a view or table. Privileges on the database do not cover access to all objects in it.

    It is different with functions: EXECUTE privilege is granted to public by default. But the function is executed with the privileges of the current user. You may be interested in the SECURITY DEFINER modifier for CREATE FUNCTION. But normally it is enough to grant SELECT on involved tables.

    Per documentation about default privileges:

    Depending on the type of object, the initial default privileges might
    include granting some privileges to PUBLIC. The default is no public
    access for tables, columns, schemas, and tablespaces; CONNECT
    privilege and TEMP table creation privilege for databases; EXECUTE
    privilege for functions; and USAGE privilege for languages.

    You may be interested in this DDL command (requires Postgres 9.0 or later):

    GRANT SELECT ON ALL TABLES IN SCHEMA public TO myuser;
    

    While connected to the database in question, of course (see @marcel’s comment below), and as a user with sufficient privileges. You may also be interested in the setting DEFAULT PRIVILEGES:

    • Grant all on a specific schema in the db to a group role in PostgreSQL

    More detailed answer how to manage privileges:

    • How to manage DEFAULT PRIVILEGES for USERs on a DATABASE vs SCHEMA?

    pgAdmin has a feature for more sophisticated bulk operations:

    enter image description here

    Or you can query the system catalogs to create DDL statements for bulk granting / revoking …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create an SQL Azure user and grant her read-only access
Is it possible to grant access to jira-user with abilty to read all administration
I wish to grant a stored procedure read access to a table in SQL
I need to grant privileges to all users, I can do: GRANT select on
We use ACLs to grant access to svn repositories. The users/groups are stored in
I have a user who I want to give readonly access to an SQL
How can I use grant and creation of a view to allow a user
How can I grant permissions to a user on a directory (Read, Write, Modify)
I want grant user rights to copy a specific file from a remote server
How do I grant a user DBA rights in Oracle? I guess something like:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.