What you will be able to do
- Place any Snowflake object at its level of the hierarchy: organization, account, database, schema, or schema object
- Predict how an object's container decides its name uniqueness, name resolution and grant prerequisites
- Choose between system-defined, custom account and database roles for administering the hierarchy
- Decide when a managed access schema should take grant control away from object owners
- Pick the right stage type and file format placement for a loading pipeline, and explain how streams, tasks and procedures behave as schema objects
Key concept
Container hierarchy — Every securable object in Snowflake lives inside one container. The organization holds accounts, the account holds account-level objects and databases, databases hold schemas, and schemas hold tables, views, stages and the rest. An object's container decides which names it must not clash with, which privileges a role needs before it can reach the object, and who controls grants on it.
1.Four levels of containment
Snowflake objects sit in a strict chain of containers, and you can't skip a level. The customer organization is at the top. Each account sits in the organization, and every database belongs to exactly one account. Each database holds schemas, and the schemas hold the objects that store or process data: tables, views, functions, stages and the other schema-level types. No database exists outside an account, and no table exists outside a schema.
Not everything lives inside a database. Users, roles, warehouses and databases themselves are account objects. They hang directly off the account and have no database or schema. That placement matters as soon as you design anything. A virtual warehouse is an independent compute cluster. It shares no compute resources with other warehouses, and it isn't owned by a schema, so a schema can't contain its own private warehouse. In the same way, an organization contains accounts. A schema can never contain an organization.
| Container | What it directly holds | Name must be unique within |
|---|---|---|
| Organization | Accounts | — |
| Account | Users, roles, warehouses, databases | The entire account |
| Database | Schemas | The database |
| Schema | Tables, views, file formats, stages, functions, procedures | The schema (functions and procedures may overload) |
| Table | Columns | The table |
Snowflake sets no hard limits on how many databases an account holds, how many schemas a database holds, or how many objects a schema holds. Choosing between one database with many schemas and many databases with few schemas is therefore a question of boundaries, not capacity. Pick the level where you want names, grants and administration to divide.
Checkpoint 1 of 8· Check yourself
An architect wants the FINANCE.REPORTING and SALES.REPORTING schemas each to have their own warehouse named REPORTING_WH, so each schema's queries get dedicated compute. What happens with this design?
Warehouses sit directly under the account, next to users, roles and databases. They are outside the database and schema hierarchy. A schema can't contain a private warehouse, and a warehouse name must be unique across the entire account.
“Identifiers for account objects (users, roles, warehouses, databases, etc.) must be unique across the entire account.”Source: docs.snowflake.com
Checkpoint 2 of 8· Exam question
An architect is documenting how a new Snowflake account will be organized before any databases are created. They need to explain to stakeholders which container directly holds databases, and which container directly holds schema-level objects such as tables and views, so that naming conventions can be planned correctly. Which statement correctly describes this containment order?
Correct answer: A — A Snowflake account directly contains databases, and each database directly contains the schemas that in turn hold tables, views, and other schema-level objects.
- A. Correct - the containment order in Snowflake runs account, then database, then schema, then schema-level objects like tables and views, so an account holds databases and a database holds schemas.
- B. Incorrect - this reverses the real order; schemas do not own databases, databases contain schemas, and the database itself sits directly under the account.
- C. Incorrect - accounts sit between an organization and its databases, so a database is never a direct child of the organization while an account layer exists.
- D. Incorrect - virtual warehouses are account-level compute resources that are not nested inside databases, so a database cannot contain a warehouse in the object hierarchy.
2.Naming and name resolution follow the containers
An identifier only has to be unique within its parent, so the hierarchy is also a namespace. Two schemas called STAGING can exist in different databases, and two tables called ORDERS can exist in different schemas. A warehouse or role name, though, must be unique across the whole account. The fully-qualified form <database_name>.<schema_name>.<object_name> tells apart objects that share a name. Write a three-part name whenever a query crosses databases, for example a company-wide report that joins tables from two business-unit databases.
When you leave out qualifiers, Snowflake fills them in from the session. In DDL and DML, an unqualified name gets the current database and schema. A <schema_name>.<object_name> reference gets the current database. In queries, an unqualified name is looked up through the SEARCH_PATH session parameter, which defaults to $current, $public. The <database_name>..<object_name> notation always points at the PUBLIC schema. Snowflake provides it for compatibility with other systems and discourages it in new code.
SELECT CURRENT_SCHEMAS();
+-------------------+
| CURRENT_SCHEMAS() |
+-------------------+
| [] |
+-------------------+
USE DATABASE mytestdb;
SELECT current_schemas();
+---------------------+
| CURRENT_SCHEMAS() |
+---------------------+
| ["MYTESTDB.PUBLIC"] |
+---------------------+Views and UDFs ignore the session's search path. Any unqualified name in a view or UDF definition resolves only in that view's or UDF's own schema. Suppose a view in REPORTING.PUBLIC refers to a bare orders. It will never find RAW.SALES.ORDERS, however the caller's session is set up. If a view has to reach a table in another schema or database, qualify the name in its definition. For how views limit what a reader can see, see Views and materialized views.
Checkpoint 3 of 8· Check yourself
The view REPORTING.PUBLIC.DAILY_SALES is defined as SELECT * FROM orders. The only table named ORDERS is RAW.SALES.ORDERS. An analyst has run ALTER SESSION to put RAW.SALES on their SEARCH_PATH and then queries the view. How does Snowflake resolve the bare name orders in the view?
Views and UDFs don't use the session's SEARCH_PATH. Snowflake resolves unqualified names in their definitions only in the view's or UDF's own schema. To reach a table in another schema or database, write the qualified name into the view definition.
“All unqualified objects in a view or UDF definition will be resolved in the view’s or UDF’s schema only.”Source: docs.snowflake.com
3.Roles and the grant path through containers
Privileges are granted to roles, roles are granted to users, and every object has exactly one owning role. That owner is, by default, the role that created the object. The details of ownership and inheritance are covered in RBAC: ownership, role hierarchy and privilege inheritance. This lesson is about how the container shapes a grant.
The first rule is that a grant on a schema object is useless on its own. A role that operates on an object in a schema needs at least one privilege on the parent database and at least one on the parent schema, usually USAGE. So a role that should see only two views in SALES_DB.REPORTING needs USAGE on SALES_DB, USAGE on REPORTING, and SELECT on each of the two views. It gets nothing else in that schema or database.
The second rule is that a role's type sets how far its grants can reach. Granting privileges to an account role permits actions on any object in the account. A database role is limited to one database and the objects inside it. Database roles can't be activated directly in a session, so you grant them to account roles. Use a database role when the permission set should stay with one database.
A new account starts with system-defined roles, each covering one administrative concern. You can't drop them, and you can't revoke the privileges Snowflake gave them. SECURITYADMIN holds the MANAGE GRANTS privilege, so it can manage any object grant across the account and create, monitor and manage users and roles. MANAGE GRANTS does not let it create objects. USERADMIN handles users and roles only, and SECURITYADMIN inherits it. SYSADMIN creates and owns the warehouses, databases and schemas that data teams build on. ACCOUNTADMIN includes both SYSADMIN and SECURITYADMIN, and only a small, controlled set of users should hold it.
Checkpoint 4 of 8· Check yourself
Your team needs a set of permissions on SALES_DB objects that stays within SALES_DB and can't reach objects in any other database. Analysts will use these permissions in their normal sessions. Which design achieves this?
A database role keeps its permissions within one database and the objects in it, so it fits the requirement. However, database roles can't be activated directly in a session. You grant the database role to an account role, and analysts activate the account role.
“Note that database roles cannot be activated directly in a session. Grant database roles to account roles, which can be activated in a session.”Source: docs.snowflake.com
Checkpoint 5 of 8· Exam question
A new Snowflake account has only the default system roles. The security team wants one role that can manage grants on any object across the account and administer users and roles globally, while a separate role should own the databases, schemas, and warehouses that the data teams actually build. Which pairing correctly matches these two responsibilities to the built-in roles designed for them?
Correct answer: A — Assign SECURITYADMIN to manage grants and user/role administration globally, and assign SYSADMIN to own the databases, schemas, and warehouses created for data teams.
- A. Correct - SECURITYADMIN can manage grants on any object account-wide and administers users and roles, while SYSADMIN is the recommended parent for custom roles that own the databases, schemas, and warehouses data teams build.
- B. Incorrect - USERADMIN is limited to creating and managing users and roles rather than managing grants on arbitrary objects, and ACCOUNTADMIN is reserved for top-level administration rather than routine object ownership.
- C. Incorrect - this swaps the intended purposes; SYSADMIN is meant to own compute and data objects, while SECURITYADMIN, not SYSADMIN, holds the global grant-management responsibility.
- D. Incorrect - PUBLIC is the default role automatically granted to every user with minimal privileges, so it cannot serve as the account's global grant-management role.
4.Managed access schemas centralise grant decisions
In a regular schema, control is spread out. Whichever role creates an object owns it, and the owner can grant or revoke privileges on it to any other role. With ten developer roles creating tables in a shared schema, that can mean ten roles granting access independently, and nobody has a single view of who can read what.
A managed access schema takes that decision away from object owners. Only the schema owner, or a role with MANAGE GRANTS such as SECURITYADMIN, can grant privileges on objects in the schema. Developers can still create tables and views, but a central team decides who reads them. Use a managed access schema when compliance needs one accountable grant authority, for example a schema of regulated customer data. Keep a regular schema for a team sandbox, where owner-controlled grants let the team move faster.
Checkpoint 6 of 8· Check yourself
Ten developer roles create tables in the shared schema CUSTOMER_PII. Each role currently grants SELECT on its own tables to whichever roles it chooses. Compliance now requires one accountable grant authority, so the schema is converted to a managed access schema. What changes for the developer roles?
A managed access schema removes grant decisions from object owners, but it doesn't stop them creating objects. Grant authority moves to the schema owner or to a role with MANAGE GRANTS, which gives compliance one central place to control who can read the data.
“However, in a managed access schema, object owners lose the ability to make grant decisions.”Source: docs.snowflake.com
Sources1
5.Pipeline objects that live inside a schema
A complete ELT pipeline can sit inside one schema. Stages, file formats, tables, views, streams, tasks, functions and procedures are all schema-level objects. They share the schema's namespace and grant boundary, and each object's owning role shapes how it behaves. Only the compute comes from outside the schema: a task that runs on a user-managed warehouse needs USAGE on that account-level warehouse.
Stages hold files before they are loaded. Each user and each table automatically gets an internal stage, and you can also create named internal stages. A user stage, referenced as @~, suits files used by one person that go into several tables. It can't be altered or dropped, and it doesn't support file format options, so you set the format in COPY INTO <table> instead. A named stage is a real schema object, so access to it is managed with grants. That makes it the choice when several users or a service share the landing area.
File formats are named schema objects that describe how staged data is parsed for loading or access, with TYPE set to CSV, JSON, AVRO, ORC, PARQUET or XML. Define a format once in the pipeline schema and every load can refer to it by name. Without one, the same parsing options get copied into each COPY statement.
Streams record DML changes on a source object for change data capture. A stream holds no table data. It stores only an offset into the source's version history. Creating the first stream on a table adds hidden change-tracking columns to that table, so the stream depends on its source and can't stand apart from it. A stream on a table and a stream on that table's clone produce the same METADATA$ROW_ID values for rows that existed when the clone was taken. Tasks run with their owner role's privileges, not the privileges of the person who scheduled them. Because of that, the role that owns a task decides what the task can read and write. For how they combine in pipelines, see Streams and tasks.
Functions and procedures are the one exception to name uniqueness within a schema. Snowflake allows several UDFs or procedures with the same identifier in one schema, told apart by their arguments. This is called overloading. A stored procedure can run with the privileges of the role that owns it rather than the caller's. That lets the owner hand a specific operation to users who otherwise lack the privilege, such as deleting rows older than a cutoff from tables those users can't touch. For the full comparison, see Stored procedures, UDFs and UDTFs.
Checkpoint 7 of 8· Check yourself
Support users must be able to delete rows older than a cutoff date from several tables in a pipeline schema. They must not get DELETE on those tables. Which design meets both requirements?
A stored procedure can run with the privileges of the role that owns it rather than the caller's. That lets the owner hand one specific operation, such as a cutoff-based delete, to users who don't hold the privilege themselves. A task runs with its owner role's privileges, not the scheduler's, and overloading only allows several functions to share a name.
“Execute code with the privileges of the role that owns the procedure, rather than with the privileges of the role that runs the procedure.”Source: docs.snowflake.com
Checkpoint 8 of 8· Exam question
A data platform team is designing a schema named ANALYTICS.SALES that will host the full set of objects needed for an ELT pipeline: raw file landing, format parsing, incremental change capture, and scheduled transformation logic, in addition to the tables and views end users will query. Which of the following are valid schema-level object types the team can create directly inside this schema to support that pipeline? (Select all that apply)(Select 4)
Correct answers: A, B, C, D — A stage object that references the external or internal location where raw source files are landed before loading.; A file format object that defines how staged files such as CSV or Parquet should be parsed during a load.; A stream object that records the change data capture information for a table so downstream tasks can consume it.; A task object that runs a scheduled SQL statement or calls a stored procedure to transform newly captured changes.
- A. Correct - stages are schema-level objects and are the standard landing point for files before a COPY INTO load brings them into a table.
- B. Correct - file formats are schema-level objects that define parsing rules like delimiter or compression and are referenced by stages or COPY INTO statements.
- C. Correct - streams are schema-level objects that track row-level inserts, updates, and deletes on a source table for consumption by downstream logic.
- D. Correct - tasks are schema-level objects that execute on a schedule or trigger and commonly consume a stream's captured changes to drive transformation.
- E. Incorrect - virtual warehouses are account-level compute resources, not schema-level objects, and a warehouse is never scoped to or owned by a single schema.
- F. Incorrect - an organization is the top-most container above accounts and has no schema-level equivalent; schemas cannot group or contain organization-level constructs.
Sources
(10)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Securable objects such as tables, views, functions, and stages are contained in a schema object, which are in turn contained in a database.”
↩︎ Four levels of containment“All databases for your Snowflake account are contained in the account object.”
↩︎ Four levels of containment“Note that database roles cannot be activated directly in a session. Grant database roles to account roles, which can be activated in a session.”
↩︎ Roles and the grant path through containers“Role that can manage any object grant globally, as well as create, monitor, and manage users and roles.”
↩︎ Roles and the grant path through containers“Role that encapsulates the SYSADMIN and SECURITYADMIN system-defined roles.”
↩︎ Roles and the grant path through containers“it is not recommended to mix account-management privileges and entity-specific privileges in the same role.”
↩︎ Roles and the grant path through containers“In a regular schema, the owner role has all privileges on the object by default”
↩︎ Managed access schemas centralise grant decisions“Every securable object resides within a logical container in a hierarchy of containers. The top-most container is the customer organization.”
↩︎ Key concept“or a role with the MANAGE GRANTS privilege can grant privileges on objects in the schema.”
↩︎ Exam trap 2“It does not give the SECURITYADMIN the ability to perform other actions such as creating objects.”
↩︎ Exam trap 3“in a managed access schema, object owners lose the ability to make grant decisions.”
↩︎ Prediction“However, in a managed access schema, object owners lose the ability to make grant decisions.”
↩︎ Checkpoint - 2.
“Each virtual warehouse is an independent compute cluster that doesn’t share compute resources with other virtual warehouses.”
↩︎ Four levels of containment - 3.https://docs.snowflake.com/en/user-guide/databasesOfficial docs
“Snowflake does not place any hard limits on the number of databases, schemas (within a database), or objects (within a schema) you can create.”
↩︎ Four levels of containment - 4.
“Identifiers for schema objects (tables, views, file formats, stages, etc.) must be unique within the schema.”
↩︎ Naming and name resolution follow the containers“Snowflake supports UDFs/stored procedures with the same identifier within the same schema (also referred to as “overloading”).”
↩︎ Pipeline objects that live inside a schema“Identifiers for account objects (users, roles, warehouses, databases, etc.) must be unique across the entire account.”
↩︎ Exam trap 1“Identifiers for account objects (users, roles, warehouses, databases, etc.) must be unique across the entire account.”
↩︎ Checkpoint - 5.
“In DDL and DML statements, unqualified objects are augmented with the current database and schema.”
↩︎ Naming and name resolution follow the containers“The SEARCH_PATH is not used inside views or UDFs.”
↩︎ Naming and name resolution follow the containers“All unqualified objects in a view or UDF definition will be resolved in the view’s or UDF’s schema only.”
↩︎ Checkpoint - 6.
“requires at least one privilege on the parent database and at least one privilege on the parent schema.”
↩︎ Roles and the grant path through containers“Required only for tasks that rely on user-managed warehouses for runs.”
↩︎ Pipeline objects that live inside a schema - 7.
“By default, each user and table in Snowflake is automatically allocated an internal stage for staging data files to be loaded.”
↩︎ Pipeline objects that live inside a schema“User stages do not support setting file format options.”
↩︎ Exam trap 4 - 8.
“Creates a named file format that describes a set of staged data to access or load into Snowflake tables.”
↩︎ Pipeline objects that live inside a schema - 9.
“Note that a stream itself does not contain any table data. A stream only stores an offset for the source object”
↩︎ Pipeline objects that live inside a schema“A stream on a source object and a stream on the source object’s clone produce the same METADATA$ROW_IDs”
↩︎ Pipeline objects that live inside a schema - 10.https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-overviewOfficial docs
“Execute code with the privileges of the role that owns the procedure, rather than with the privileges of the role that runs the procedure.”
↩︎ Pipeline objects that live inside a schema