Resolve Snowflake "access denied" errors by inspecting role privileges and granting the exact rights required to run the blocked statement.
Snowflake returns "access denied" when your current role lacks a privilege—USAGE on a database, SELECT on a table, EXECUTE on a warehouse, etc.—needed by the statement you just ran. The error text usually lists the blocked object.
Run SELECT CURRENT_ROLE();
to confirm the active role.Then query SHOW GRANTS TO ROLE <role_name>;
to list every privilege that role holds on every object.
Compare the object in the error message to the grants list.If the role lacks USAGE on the database or schema, or SELECT on the table, that privilege is the culprit.
Connect as a SECURITYADMIN-level role (or any role with the MANAGE GRANTS & USAGE rights) and issue an explicit GRANT statement.Use the fully qualified object name to avoid ambiguity.
GRANT USAGE ON DATABASE sales_db TO ROLE analyst;
GRANT SELECT ON TABLE sales_db.public.orders TO ROLE analyst;
Switch back to the blocked user’s role with USE ROLE analyst;
and re-run the original query. If it succeeds, you granted the correct privilege.If not, repeat the privilege gap analysis.
Create dedicated roles (e.g., ANALYST_READ) mapped to business activities, grant only the minimal rights they need, and apply them to users instead of ad-hoc direct grants.
Granting on the wrong object level – Granting SELECT on the database instead of the table appears to work but does not cover table access.Always grant at the exact object level.
Skipping USAGE grants – Even with SELECT on a table, the role still needs USAGE on its database and schema. Grant both layers.
Yes. USAGE lets the role see the database and schema. SELECT (or INSERT/UPDATE) allows interaction with the table itself.
Yes, prefix the GRANT with the keyword ALL
on SCHEMA to cover future tables, or use GRANT ... ON FUTURE TABLES IN SCHEMA
.
SECURITYADMIN or any role with OWNERSHIP on the target object is sufficient to issue GRANT statements.