Bird
Raised Fist0
SnowflakeConceptBeginner · 3 min read

What is PUBLIC Role in Snowflake: Explanation and Usage

In Snowflake, the 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

This example shows how to check the privileges granted to the PUBLIC role and how it affects user access.
sql
SHOW GRANTS TO ROLE PUBLIC;

-- To see what a user can access including PUBLIC role
SHOW GRANTS TO USER some_user;
Output
Role: PUBLIC Granted Privileges: - USAGE on DATABASE sample_db - USAGE on SCHEMA sample_db.public - SELECT on TABLE sample_db.public.some_table User: some_user Roles: PUBLIC, analyst Privileges: Combined from all roles including PUBLIC
🎯

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 PUBLIC role.
  • Common access: Used to grant permissions shared by all users.
  • Not for sensitive data: Avoid putting critical permissions here.
  • Combined permissions: User permissions include PUBLIC plus any other assigned roles.
✅

Key Takeaways

The PUBLIC role is automatically assigned to every Snowflake user.
It grants basic, shared permissions to all users.
Use PUBLIC for common access, not sensitive data.
User access combines PUBLIC role permissions with other roles.
Check PUBLIC role grants to understand default user access.