Last active
September 14, 2022 19:33
-
-
Save LyleScott/3f3bc7104a8d37c932f380e46ee4d161 to your computer and use it in GitHub Desktop.
Create a read only role in Snowflake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- create the read-only role. | |
create role if not exists YOUR_ROLE_NAME; | |
-- allow the role to access a specific warehouse | |
grant usage on warehouse YOUR_WAREHOUSE_NAME to role YOUR_ROLE_NAME; | |
-- allow the role to access a specific schema (most likely public?) | |
//grant usage on all schemas in database YOUR_DATABASE_NAME to role YOUR_ROLE_NAME; | |
grant usage on schema PUBLIC to role YOUR_ROLE_NAME; | |
-- allow the role to access a specific database | |
grant usage on database YOUR_DATABASE_NAME to role YOUR_ROLE_NAME; | |
-- allow the role access to all tables in a database (and that will be created in future...) | |
grant select on future tables in database YOUR_DATABASE_NAME to role YOUR_ROLE_NAME; | |
grant select on all tables in database YOUR_DATABASE_NAME; | |
-- allow the role access to all views in a database (and that will be created in future...) | |
grant select on future views in database YOUR_DATABASE_NAME to role YOUR_ROLE_NAME; | |
grant select on all views in database YOUR_DATABASE_NAME; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
grant select on all tables in database YOUR_DATABASE_NAME;
should be
grant select on all tables in database YOUR_DATABASE_NAME to role YOUR_ROLE_NAME;
same things with views