Skip to content

Instantly share code, notes, and snippets.

@LyleScott
Last active September 14, 2022 19:33
Show Gist options
  • Save LyleScott/3f3bc7104a8d37c932f380e46ee4d161 to your computer and use it in GitHub Desktop.
Save LyleScott/3f3bc7104a8d37c932f380e46ee4d161 to your computer and use it in GitHub Desktop.
Create a read only role in Snowflake
-- 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;
@krishna2034
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment