What is PUBLIC Role in Snowflake: Explanation and Usage
PUBLIC role is a default role automatically assigned to every user. It grants basic access permissions that apply to all users, such as access to public objects or shared resources.How It Works
The PUBLIC role in Snowflake works like a basic access pass that every user gets automatically. Imagine it as a general admission ticket to a concert that lets you enter the venue but not the VIP areas. This role contains permissions that apply to all users, so you don't have to assign common rights individually.
For example, if there are shared databases or tables meant for everyone, the PUBLIC role can hold the permissions to access them. When a user logs in, Snowflake automatically includes the PUBLIC role along with any other roles assigned, combining their permissions.
Example
PUBLIC role and how it affects user access.SHOW GRANTS TO ROLE PUBLIC;
-- To see what a user can access including PUBLIC role
SHOW GRANTS TO USER some_user;When to Use
Use the PUBLIC role to give all users access to common resources without assigning permissions repeatedly. For example, if you have a shared dataset or a public view that everyone in your organization should see, grant access to the PUBLIC role.
However, avoid putting sensitive permissions in PUBLIC because it applies to every user, including new ones. Instead, use specific roles for restricted access.
Key Points
- Default role: Every user automatically has the
PUBLICrole. - Common access: Used to grant permissions shared by all users.
- Not for sensitive data: Avoid putting critical permissions here.
- Combined permissions: User permissions include
PUBLICplus any other assigned roles.
