Schema level SELECT on all new tables
Hi,
I am trying to work on a scenario , where one user creates tables in a 'schema', and all such tables should be visible to a specific user/role, even if the tables are created in future (after grant SELECT command).
My current flow is as:
USERS: dbadmin, user1, user2
SCHEMA: myschema
dbadmin=> GRANT ALL ON SCHEMA myschema to user1; dbadmin=> GRANT SELECT ON ALL TABLES IN SCHEMA myschema TO user2; dbadmin=> ALTER SCHEMA myschema DEFAULT INCLUDE PRIVILEGES; -- user1 now creates table user1=> CREATE TABLE myschema.table1 (id INT); -- can user2 see that table user2=> SELECT * FROM myschema.table1; -- Permission Denied for table1
Any ideas on how this can be solved ?
Thanks
0
Comments
When inherited privileges are enabled on a schema, all privileges granted to the schema are automatically granted to all newly created tables or views in the schema. Note that you still must grant privileges on the schema to a user. Let me know if this is what you're looking for:
Thanks @Shayon_Sanyal
I was trying to use 'grant select on all tables', instead of 'grant select on schema'.
Works like a charm.