0
0
Snowflakecloud~10 mins

Creating and managing shares in Snowflake - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Creating and managing shares
Start
Create Share
Add Database Objects to Share
Grant Access to Consumers
Manage Share (Add/Remove Objects)
Monitor Share Usage
End
The flow shows creating a share, adding objects, granting access, managing content, and monitoring usage.
Execution Sample
Snowflake
CREATE SHARE my_share;
GRANT USAGE ON DATABASE my_db TO SHARE my_share;
ALTER SHARE my_share ADD SCHEMA my_db.my_schema;
GRANT SELECT ON TABLE my_db.my_schema.my_table TO SHARE my_share;
This code creates a share, adds a database and schema, and grants select access on a table.
Process Table
StepActionObject AffectedResultNotes
1CREATE SHARE my_share;Share: my_shareShare createdShare is empty initially
2GRANT USAGE ON DATABASE my_db TO SHARE my_share;Database: my_dbUsage granted to shareShare can now reference database
3ALTER SHARE my_share ADD SCHEMA my_db.my_schema;Schema: my_schemaSchema added to shareObjects in schema become shareable
4GRANT SELECT ON TABLE my_db.my_schema.my_table TO SHARE my_share;Table: my_tableSelect granted to shareConsumers can query this table
5GRANT SHARE my_share TO ACCOUNT consumer_account;Consumer AccountAccess grantedConsumer can now use the share
6ALTER SHARE my_share REMOVE SCHEMA my_db.my_schema;Schema: my_schemaSchema removed from shareObjects no longer shared
7DROP SHARE my_share;Share: my_shareShare droppedShare no longer exists
💡 Share dropped or no longer needed, ending management.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7
my_shareundefinedcreatedcreated with db usagecreated with schemacreated with table selectshared with consumerschema removeddropped
my_dbexistsexistsusage granted to shareusage granted to shareusage granted to shareusage granted to shareusage granted to shareusage granted to share
consumer_accountno accessno accessno accessno accessno accessaccess grantedaccess grantedaccess revoked
Key Moments - 3 Insights
Why do we need to grant USAGE on the database to the share before adding schemas or tables?
Granting USAGE on the database (see Step 2) allows the share to reference objects inside it. Without this, adding schemas or tables to the share will fail.
What happens if we remove a schema from the share after granting access?
Removing the schema (Step 6) removes all objects inside it from the share, so consumers lose access to those objects even if they had access before.
Does creating a share automatically give access to any consumer accounts?
No, creating a share (Step 1) only creates it. Access must be explicitly granted to consumer accounts (Step 5) to allow usage.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the state of 'my_share' after Step 3?
AShare created with database usage granted
BShare created with schema added
CShare dropped
DShare created with table select granted
💡 Hint
Check the 'Result' column in Step 3 of the execution table.
At which step does the consumer account gain access to the share?
AStep 5
BStep 4
CStep 2
DStep 6
💡 Hint
Look for 'Access granted' in the 'Result' column.
If we skip granting USAGE on the database to the share, what will happen when adding schemas?
ASchemas will be added successfully
BConsumer accounts get access automatically
CAdding schemas will fail
DShare will be dropped automatically
💡 Hint
Refer to the key moment about granting USAGE before adding schemas.
Concept Snapshot
CREATE SHARE share_name;
GRANT USAGE ON DATABASE db_name TO SHARE share_name;
ALTER SHARE share_name ADD SCHEMA db_name.schema_name;
GRANT SELECT ON TABLE db_name.schema_name.table_name TO SHARE share_name;
GRANT SHARE share_name TO ACCOUNT consumer_account;
Use ALTER SHARE to add or remove objects; DROP SHARE to delete.
Full Transcript
Creating and managing shares in Snowflake involves first creating a share object. Then, you grant usage on the database to the share so it can reference objects inside. Next, you add schemas and grant select privileges on tables to the share. After that, you grant access to consumer accounts so they can use the shared data. You can manage the share by adding or removing schemas and tables as needed. Finally, you can drop the share when it is no longer needed. Each step changes the state of the share and its accessibility.