Someone asked me how to list all tables that a given user can select from. They’ve got a special user for a client, so the client can make its own sql queries but due to the security policy, that user can only select and only from some tables. They wanted to give the client a list of tables that can be selected.
Let’s name the user: ’super_me’. Such a report can be generated using this simple query:
SELECT
schemaname||'.'||tablename
FROM
pg_tables
WHERE
has_table_privilege (
'super_me',
schemaname||'.'||tablename,
'select'
)
AND
schemaname NOT IN (
'pg_catalog',
'information_schema'
);
Related posts:
- PostgreSQL Wishlist PostgreSQL is a great database, in my opinion much...
- How to Allow For Max 4 Rows in Update (PostgreSQL) The Problem Question found on the net: how to restrict...
- PostgreSQL FOUND Problem FOUND is a global variable that exists in the plpgsql...
- PostgreSQL Strange Timings A very simple query. PostgreSQL 8.4. I have no idea...
- PostgreSQL Collation – part 1 PostgreSQL is (IMHO) much better than MySQL but unfortunately it ...
- PostgreSQL Collation – part 2 Due to many questions about the PostgreSQL collation that were...













One Response
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Continuing the Discussion