What you will be able to do
- Create zero-copy clones of databases, schemas and tables, and explain how clone storage diverges from the source over time
- Predict the state of tasks, pipes, alerts, streams, stages and clustering in a fresh clone, and what to resume before testing
- Work out which grants a cloned database, schema or table keeps, and when COPY GRANTS applies
- Build a development or rollback copy from a past state with CREATE … CLONE … AT | BEFORE
- Validate changes in a clone, promote them atomically, and choose between UNDROP and a point-in-time clone to roll back
Key concept
Zero-copy clone — A clone is a new, writable object that starts out pointing at the same stored data as its source. It costs no extra storage until someone changes data in the clone, and from then on only the changed data is stored separately.
1.Cloning a database, schema or table
A development environment is only useful if it looks like production, and copying production row by row is slow and expensive. Snowflake's answer is CREATE <object> … CLONE. It is a variant of the usual CREATE command with the CLONE keyword added, and it is mainly used to make zero-copy clones of databases, schemas and tables. One statement such as CREATE DATABASE dev_db CLONE prod_db; gives analysts a full-size copy of a 40 TB production database to test against. No export, no reload, and no second 40 TB of storage on day one.
CREATE [ OR REPLACE ] { DATABASE | SCHEMA } [ IF NOT EXISTS ] <object_name>
CLONE <source_object_name>
[ { AT | BEFORE } ( { TIMESTAMP => <timestamp> | OFFSET => <time_difference> | STATEMENT => <id> } ) ]
[ IGNORE TABLES WITH INSUFFICIENT DATA RETENTION ]
[ IGNORE HYBRID TABLES ]
[ INCLUDE INTERNAL STAGES ]Storage starts out shared and splits apart only when something changes. A new clone adds nothing to storage. That changes once the clone is modified: rows added, deleted or updated in a cloned table, or a new populated table created in a cloned schema. So a regression-test schema cloned six weeks ago can show growing table sizes while the source stays flat. The growth is real. It is the new data written by DML against the clone, and the micro-partitions both objects still share are not counted twice. Changes go in neither direction: edits to the source never show up in the clone, and edits to the clone never show up in the source.
Cloning a database or schema is recursive. A database clone includes every schema and every object inside it. A schema clone includes everything in that schema. There are limits. The clone holds only the objects the cloning role has the right privileges on. External tables are never cloned. Hybrid tables can be cloned with a database but not with a schema. To clone at all, the role needs USAGE on a source database, SELECT on a source table, and OWNERSHIP on any alerts, pipes, streams and tasks it clones. External stages are cloned too, but a clone of an external stage has no effect on the bucket or container it points to.
Permission inheritance in a clone depends on which level you clone. When the source is a database or schema, the clone inherits all granted privileges on the clones of the child objects inside it, so a table that a role could read in prod_db is still readable by that role in the clone, provided the role can reach it. The cloned container is the exception: the new database or schema does not inherit the privileges granted on the source container, and access to it must be granted again. A table cloned on its own inherits no explicit privileges unless COPY GRANTS is specified.
Checkpoint 1 of 9· Fill the gap
Your team needs a writable, full-size copy of a 40 TB production database for testing. It must not add another 40 TB of storage on day one. Which keyword completes the syntax?
CREATE [ OR REPLACE ] { DATABASE | SCHEMA } [ IF NOT EXISTS ] <object_name>
? <source_object_name>
[ { AT | BEFORE } ( { TIMESTAMP => <timestamp> | OFFSET => <time_difference> | STATEMENT => <id> } ) ]
[ IGNORE TABLES WITH INSUFFICIENT DATA RETENTION ]
[ IGNORE HYBRID TABLES ]
[ INCLUDE INTERNAL STAGES ]Adding the CLONE keyword to CREATE makes a zero-copy clone. The clone points at the source's existing micro-partitions, so it adds no storage until data in the clone changes. Copying rows, as CREATE ... AS SELECT does, would store the data a second time.
Source: docs.snowflake.comCheckpoint 2 of 9· Exam question
A data engineering team wants to spin up a full-size copy of a 40 TB production database for analysts to test transformation logic against realistic data, without waiting for a bulk export/import and without doubling storage costs on day one. Which approach satisfies this requirement?
Correct answer: A — Run CREATE DATABASE dev_db CLONE prod_db; to create a zero-copy clone sharing the source's micro-partitions until either side is modified.
- A. Cloning a database is a metadata-only operation: the new database references the same micro-partitions as the source, so it is created almost instantly and does not double storage until DML diverges the two copies. This is the mechanism designed exactly for this scenario.
- B. Exporting and reloading every table through a stage moves the full 40 TB through unload and load jobs, which is far slower than a metadata-only clone and immediately consumes new storage for the reload.
- C. Granting direct read access to production does not give analysts an isolated environment to test transformation logic in; any writes or schema experiments they run would affect the live production objects.
- D. There is no
CREATE DATABASE ... AS SELECTconstruct in Snowflake, and even a row-by-row materialization would allocate new storage for every row immediately rather than sharing the source's micro-partitions.
Checkpoint 3 of 9· Exam question
Six weeks after a schema was cloned for regression testing, the clone's table sizes in TABLE_STORAGE_METRICS have grown even though the original schema's size stayed flat. Which explanation matches how Zero-Copy Cloning charges for storage over time?
Correct answer: B — The clone and source initially share the same micro-partitions, and new storage is only allocated once DML against the clone rewrites or adds micro-partitions.
- A. Cloning does not copy micro-partitions into new physical storage at creation time; that would make cloning as slow and storage-heavy as a full copy, which defeats the purpose of zero-copy cloning.
- B. This matches copy-on-write behavior: the clone shares the source's micro-partitions until DML on the clone rewrites or adds partitions, which is exactly why the clone's reported size grows independently over six weeks of regression testing activity.
- C.
TABLE_STORAGE_METRICSreflects real storage consumption, not a double-counting artifact; growth in the clone's reported size corresponds to genuine new micro-partitions created by writes against the clone. - D. Clones do not receive a separate fixed storage quota, and Time Travel retention accruing on its own does not consume additional storage the way new or modified micro-partitions from DML do.
2.What arrives in the clone, and in what state
A clone copies the data, but anything that acts on its own schedule arrives switched off. Automated objects come over inactive, so a copy of production cannot start loading files, firing alerts or running schedules unnoticed. Some state is not carried over at all: load history, unconsumed stream records and files in table stages. Before you test a pipeline in a clone, check each object in this table.
| Object | State in the clone | To make it active or correct |
|---|---|---|
| Task | Suspended by default | ALTER TASK … RESUME, one task at a time |
| Pipe, AUTO_INGEST = FALSE | Paused by default | ALTER PIPE … RESUME |
| Pipe, AUTO_INGEST = TRUE | STOPPED_CLONED: does not collect event notifications | ALTER PIPE … RESUME; after that it processes only new notifications |
| Alert | Suspended by default | ALTER ALERT … RESUME |
| Stream | Unconsumed records are inaccessible | Nothing to resume; the stream starts from the clone's history |
| Table with a clustering key | Key is kept; Automatic Clustering is suspended | ALTER TABLE <name> RESUME RECLUSTER |
| Table stage | Cloned empty; files are not copied | Restage any files you need |
| Internal named stage | Cloned only with INCLUDE INTERNAL STAGES | Files are copied only for stages with a directory table |
| Sequence used as a column default | Cloned sequence if the same clone includes it; otherwise the source sequence | ALTER TABLE <table_name> ALTER COLUMN <column_name> SET DEFAULT <new_sequence>.nextval |
Two of these rows can cost you money or cause bad data in production. First, a cloned table does not get the source table's load history. Files already loaded into production can therefore be loaded again into the clone, and the clone will not skip them. Second, a cloned table with a clustering key keeps the key, but Automatic Clustering starts out suspended even if it runs on the source. A dev copy of a clustered events table therefore does not recluster until someone runs RESUME RECLUSTER. Object parameters set on the source also carry over to the clone, so a table with a long data retention setting keeps it in the dev copy.
Checkpoint 4 of 9· Check yourself
A production schema has a Snowpipe with AUTO_INGEST = TRUE. You clone the schema for testing. New files land in the stage over the next two days, and then an engineer runs ALTER PIPE … RESUME on the cloned pipe. What does the cloned pipe load?
A cloned auto-ingest pipe starts in STOPPED_CLONED and does not collect event notifications. Once resumed, it processes only new notifications, so files staged before the resume are not loaded automatically.
“When a pipe is explicitly resumed, it only processes data files triggered as a result of new event notifications.”Source: docs.snowflake.com
3.Which grants a clone keeps
When you clone a database or schema, the objects inside keep their grants, but the cloned database or schema itself gets none. Every child object (schemas in a database; tables and views in a schema) is cloned with all the privileges granted on its source. The new database or schema does not get the privileges granted on the source container. Pipes are an exception: the role that created the clone owns the cloned pipes.
Not yet. The cloned table keeps its SELECT grant, and the cloned schema keeps its grants because it is a child object. USAGE on dev_db itself is not copied, though. An administrator has to run GRANT USAGE ON DATABASE dev_db TO ROLE ANALYST before the query will work.
Cloning a single table works differently, and COPY GRANTS controls what happens. Most CREATE … CLONE statements do not copy the source object's grants. CREATE TABLE … CLONE supports COPY GRANTS, though. With COPY GRANTS, the clone gets every explicit privilege on the source except OWNERSHIP, but no future grants defined in the schema. Without it, the clone gets no explicit privileges from the source but does pick up the schema's future grants. Grants that end up missing are added with GRANT <privileges> … TO ROLE.
| How the clone is created | Privileges on the clone |
|---|---|
| Child object inside a cloned database or schema | All privileges granted on the source child object |
| The cloned database or schema itself | None from the source container |
| CREATE TABLE … CLONE without COPY GRANTS | Future grants for tables in the schema; no explicit grants from the source |
| CREATE TABLE … CLONE with COPY GRANTS | Explicit grants from the source except OWNERSHIP; no future grants |
| CREATE OR REPLACE TABLE … CLONE … COPY GRANTS over an existing name | Grants copied from the table being replaced |
| Cloned pipe | OWNERSHIP held by the role that created the clone |
The last COPY GRANTS row matters when you promote a change. If the statement replaces an existing table with the same name, the grants come from the table being replaced, not from the clone source. Replacing a production table with a tested dev clone therefore keeps production's grants, not the dev environment's.
Checkpoint 5 of 9· Check yourself
During promotion, an engineer runs CREATE OR REPLACE TABLE prod_db.sales.orders CLONE dev_db.sales.orders COPY GRANTS. In dev, only DEV_ENGINEER has SELECT on the table. In production, REPORTING and FINANCE have SELECT on the existing orders table. After the statement runs, which explicit grants are on prod_db.sales.orders?
When CREATE OR REPLACE TABLE … CLONE … COPY GRANTS replaces a table that already has that name, the grants come from the table being replaced, not from the clone source. Promoting a tested dev clone this way keeps production's grants.
“If the statement is replacing an existing table of the same name, then the grants are copied from the table being replaced.”Source: docs.snowflake.com
4.Cloning a past state with AT | BEFORE
Adding Time Travel (retention period and AT | BEFORE) to a clone gives you a copy of an object as it was at an earlier point, not as it is now. Time Travel keeps changed and deleted data for the object's retention period. On Enterprise Edition, permanent tables, schemas and databases can keep it for up to 90 days. For databases, schemas and non-temporary tables, CLONE accepts AT | BEFORE with a TIMESTAMP, an OFFSET in seconds or a STATEMENT query ID. BEFORE(STATEMENT => id) gives the state just before that statement's changes, which is how you build a rollback copy from before a bad load. The query ID has to be from the last 14 days.
For a database or schema clone, the shortest retention period among its tables limits how far back you can go. Say database db1 keeps seven days of history but its table t1 keeps only one. Cloning db1 as of 12 hours ago works. Cloning it as of two days ago fails, because t1's history from that point is already gone. IGNORE TABLES WITH INSUFFICIENT DATA RETENTION skips those tables so that the rest of the clone still succeeds.
CREATE DATABASE restored_db CLONE my_db AT(TIMESTAMP => DATEADD(days, -4, current_timestamp)::timestamp_tz) IGNORE TABLES WITH INSUFFICIENT DATA RETENTION;A point-in-time clone takes the data as it was then, but not every other part of the object. Its name and structure come from the chosen point. Other metadata, such as comments and clustering keys, comes from the source as it is when the statement runs. Internal stages are cloned in their current state even when you use Time Travel. Tasks are not cloned at all when you run CREATE SCHEMA … CLONE with a timestamp. Child objects that did not exist yet at that point are left out. Cloning an object as of a time before it existed returns an error.
Even a clone without AT uses Time Travel. Snowflake sets the AT point to the moment the statement started, so a long clone stays consistent. If DML hits a source table with retention set to 0 while the clone is running, the data the clone needs may already be purged, and the clone fails with Data is not available. Avoid DML on the source until the clone finishes. If you can't, set DATA_RETENTION_TIME_IN_DAYS=1 on the tables first. Also avoid renaming a table to the name of a just-dropped table during a clone, because that causes name conflicts.
Checkpoint 6 of 9· Fill the gap
A bad load four days ago corrupted my_db. You want a rollback copy from before it. Some transient tables in my_db keep only one day of history, and the clone must still succeed. The value you are passing is a calculated date and time, not a number of seconds or a query ID. Which parameter completes the AT clause?
CREATE DATABASE restored_db CLONE my_db AT( ? => DATEADD(days, -4, current_timestamp)::timestamp_tz) IGNORE TABLES WITH INSUFFICIENT DATA RETENTION;DATEADD(...)::timestamp_tz produces a date and time, so the parameter is TIMESTAMP. OFFSET takes a difference in seconds and STATEMENT takes a query ID. IGNORE TABLES WITH INSUFFICIENT DATA RETENTION skips the one-day tables, so the rest of the database clone still succeeds.
Source: docs.snowflake.com5.Validating in a clone and promoting the result
A clone is a safe place to test because it is writable and independent of its source. You can run a breaking migration script against CREATE DATABASE dev_db CLONE prod_db, resume the cloned tasks one at a time, and check how downstream views and tasks behave. None of it touches production data. The independence has limits, though, and the risks come from references that point back to production.
Check these references before you trust a test run in a clone:
- Pipes: when a file lands in a stage location, every pipe that matches that location gets the notification. If the COPY statement in a pipe uses a fully qualified table name, Snowpipe loads duplicate data into that production table for each pipe. Pipes that use unqualified names load into the table in each database instead.
- Sequences: a table cloned by itself still takes default values from the source sequence, so test inserts use up production sequence numbers until you change the column default.
- Foreign keys: a table whose primary-key table was not cloned with it still references the source table's primary key.
- Load history: files already loaded into production can be loaded again into the clone, so a test load may not match what production would do.
Once a change has passed in the clone, you can promote it atomically. CREATE OR REPLACE statements are atomic: Snowflake deletes the old object and creates the new one in a single transaction. Readers therefore never see a moment when the table is missing. CREATE OR REPLACE TABLE prod.sales.orders CLONE dev.sales.orders COPY GRANTS puts the tested table in production's place without copying any data. Because it replaces an existing name, it keeps the production table's grants.
Checkpoint 7 of 9· Check yourself
Tomorrow you will promote a tested table with CREATE OR REPLACE TABLE prod.sales.orders CLONE dev.sales.orders COPY GRANTS. If the change goes wrong, you must be able to roll back to today's production data, and the rollback copy should add no storage until the tables diverge. What should you do?
A cloned table's Time Travel history starts when the clone was created. After the promotion, Time Travel on the new production table cannot reach the old data. A zero-copy clone of the current production table, taken before the swap, costs nothing until the tables diverge and serves as the rollback copy. Exporting the table copies every row, and the dev table never held production's current state.
“If a table is cloned, historical data for the table clone begins at the time/point when the clone was created.”Source: docs.snowflake.com
6.Rolling back: UNDROP or a point-in-time clone
The right rollback depends on what went wrong. If the object was dropped, use UNDROP. If the object still exists but its data is wrong, use a point-in-time clone. UNDROP brings back the original object in place, in its most recent state before the DROP. It does not create a new object, and it fails if an object with that name already exists. When a replacement table now has the name, rename the replacement first, then UNDROP. Creating a new table with the old name does not restore anything. It adds another version, and the dropped one can still be restored.
A point-in-time clone is the tool when the object still exists and the problem is in its data. Examples are a bad MERGE or a promoted transformation that wrote wrong values. Clone the object as it was before the faulty statement, check the result, then promote it with CREATE OR REPLACE … CLONE. Unlike UNDROP, you pick the exact point to return to, and you can inspect the result before it replaces anything. Remember the limit from cloning: the source object must have existed at that point. A table created by the promotion has no history before the promotion. To go back past that point, use the backup clone or the dropped version.
CREATE DATABASE restored_db CLONE my_db BEFORE(STATEMENT => '8e5d0ca9-005e-44e6-b858-a8f5b37c5726');| Situation | Rollback | Constraint |
|---|---|---|
| Table or schema was dropped | UNDROP TABLE / UNDROP SCHEMA | Rename any object now using the name first; needs OWNERSHIP plus CREATE privilege in the container |
| Bad DML inside an existing table | CREATE TABLE … CLONE … BEFORE(STATEMENT => id), then CREATE OR REPLACE to promote | Point must be inside retention; STATEMENT ID from the last 14 days |
| Bad promotion replaced the table | CREATE OR REPLACE … CLONE from a pre-promotion backup clone | The new table's history begins at the promotion |
| Change is older than the retention period | None you can run yourself | Data is in Fail-safe; only Snowflake can recover it |
Self-service recovery ends when the retention period ends. After that, past objects can no longer be cloned or undropped. The data moves into Fail-safe for 7 days, and only Snowflake can recover it. Take a table with a one-day retention period whose critical row was deleted four days ago. The team has no clone and no UNDROP that can reach that row. Each change gets its own deadline, the time of the change plus the retention period, so set the retention period with your rollback window in mind.
Checkpoint 8 of 9· Match them up
Each incident needs a different way back. Match each situation to the rollback that works for it.
Tap a term, then the definition that fits it.
UNDROP restores a dropped object in place, but it fails while another object has the name, so the replacement must be renamed first. Bad data in a table that still exists calls for a point-in-time clone. A promoted table has no history before the promotion, so the backup clone is the way back. Once the retention period has passed, only Snowflake can recover the data from Fail-safe.
“If an object with the same name already exists, UNDROP fails. You must rename the existing object”Source: docs.snowflake.com
Checkpoint 9 of 9· Exam question
On a Snowflake account running Enterprise Edition, what is the maximum value that can be configured for DATA_RETENTION_TIME_IN_DAYS on a permanent table?
Correct answer: C — 90 days
- A. 0 days is a valid setting that effectively disables Time Travel for the object, but it is the minimum, not the maximum, retention value available.
- B. 1 day is the default retention period across all editions, but Enterprise Edition allows configuring a longer period than this default.
- C. Enterprise Edition (and higher) permits
DATA_RETENTION_TIME_IN_DAYSto be set anywhere from 0 up to 90 days for permanent objects, which is the correct maximum. - D. 365 days exceeds what any Snowflake edition supports for
DATA_RETENTION_TIME_IN_DAYS; the documented ceiling for permanent objects is 90 days.
Sources
(3)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“This command is primarily used for creating zero-copy clones of databases, schemas, and tables.”
↩︎ Cloning a database, schema or table“Adding, deleting, or modifying rows in a cloned table.”
↩︎ Cloning a database, schema or table“Cloning includes only the objects on which the role that creates the clone has appropriate privileges.”
↩︎ Cloning a database, schema or table“A cloned table does not include the load history of the source table.”
↩︎ What arrives in the clone, and in what state“does not inherit any future grants defined for the object type in the schema”
↩︎ Which grants a clone keeps“If the statement is replacing an existing table of the same name, then the grants are copied from the table being replaced.”
↩︎ Which grants a clone keeps“Snowflake makes clones of internal stages in their current state, regardless of whether your CREATE CLONE statement uses Time Travel”
↩︎ Cloning a past state with AT | BEFORE“A clone is writable and is independent of its source.”
↩︎ Validating in a clone and promoting the result“when an object is replaced, the old object is deleted and the new object is created in a single transaction.”
↩︎ Validating in a clone and promoting the result“a clone does not contribute to the overall data storage for the object until operations are performed on the clone”
↩︎ Key concept“a clone does not contribute to the overall data storage for the object until operations are performed on the clone”
↩︎ Exam trap 1 - 2.
“cloning an external stage has no impact on the referenced cloud storage.”
↩︎ Cloning a database, schema or table“Cloning is fast, but not instantaneous, particularly for large objects”
↩︎ Cloning a database, schema or table“the clone inherits all granted privileges on the clones of all child objects contained in the source object”
↩︎ Cloning a database, schema or table“The clone of the container itself (database or schema) doesn’t inherit the privileges granted on the source container.”
↩︎ Cloning a database, schema or table“When AUTO_INGEST = TRUE, a cloned pipe is set to the STOPPED_CLONED state.”
↩︎ What arrives in the clone, and in what state“By default, Automatic Clustering is suspended for the new table.”
↩︎ What arrives in the clone, and in what state“the clone inherits all granted privileges on the clones of all child objects contained in the source object”
↩︎ Which grants a clone keeps“For pipes, the role that creates the clone has the OWNERSHIP privilege on the pipes.”
↩︎ Which grants a clone keeps“inherits any other metadata, such as comments or table clustering keys, that is current in the source object”
↩︎ Cloning a past state with AT | BEFORE“the cloning operation internally sets the AT clause value as the timestamp when the statement was initiated.”
↩︎ Cloning a past state with AT | BEFORE“Snowpipe loads duplicate data into the source table”
↩︎ Validating in a clone and promoting the result“If a table is cloned, historical data for the table clone begins at the time/point when the clone was created.”
↩︎ Validating in a clone and promoting the result“If the source object didn’t exist at the time/point set in the AT | BEFORE clause, an error is returned.”
↩︎ Rolling back: UNDROP or a point-in-time clone“When AUTO_INGEST = TRUE, a cloned pipe is set to the STOPPED_CLONED state.”
↩︎ Exam trap 2“The clone of the container itself (database or schema) doesn’t inherit the privileges granted on the source container.”
↩︎ Exam trap 3“When a database or schema that contains tasks is cloned, the tasks in the clone are suspended by default.”
↩︎ Prediction“When a pipe is explicitly resumed, it only processes data files triggered as a result of new event notifications.”
↩︎ Checkpoint - 3.
“For permanent databases, schemas, and tables, the retention period can be set to any value from 0 up to 90 days.”
↩︎ Cloning a past state with AT | BEFORE“Calling UNDROP restores the object to its most recent state before the DROP command was issued.”
↩︎ Rolling back: UNDROP or a point-in-time clone“If an object with the same name already exists, UNDROP fails.”
↩︎ Rolling back: UNDROP or a point-in-time clone“Past objects can no longer be cloned.”
↩︎ Rolling back: UNDROP or a point-in-time clone“During that time, only Snowflake can recover it.”
↩︎ Rolling back: UNDROP or a point-in-time clone“After dropping an object, creating an object with the same name does not restore the object.”
↩︎ Exam trap 4“If an object with the same name already exists, UNDROP fails. You must rename the existing object”
↩︎ Checkpoint