Study FAQ
Why can I sign in to Snowflake but still get an access denied error when I query data?
Also asked as 2
- How do I find the missing role or grant when a Snowflake query fails after login?
- What should I check if an administrator can run a Snowflake query but my user cannot?
Answer
Once sign-in succeeds, check the failing session's account, active roles, warehouse and object path. For a warehouse-backed SELECT, the active and inherited roles generally need warehouse USAGE, access to the database and schema, and SELECT on the named table or view.
- In the failing session, check
CURRENT_ROLE(),CURRENT_SECONDARY_ROLES(),CURRENT_WAREHOUSE(),CURRENT_DATABASE()andCURRENT_SCHEMA(). Compare the account and a fully qualified object name with the working session. A user's default role sets initial context and must already have been granted to that user. A client connection can choose a different role. - With a diagnostic role that has sufficient visibility, use
SHOW GRANTS TO USERandSHOW GRANTS TO ROLEand follow inherited account and database roles to the required grants. Check whether the administrator is succeeding through an ownership path that the functional role lacks. - Correct the missing link, then repeat the original query with the intended user, role and warehouse. If you isolate the test with
USE SECONDARY ROLES NONE, restore the application's normal role configuration before final verification.
CURRENT_ROLE() reports the primary role. Most statements can use privileges from active primary and secondary roles and their hierarchies. Authorization to create an object uses the primary role and its hierarchy, and the active primary role owns the new object.
Access control overview · Access control privileges · SHOW GRANTS · USE SECONDARY ROLES
Full explanation
Managing Snowflake Accounts, Organizations, Roles, and Access
Study guide · COF-C03
Read the full explanation