Historical Dev/QA clones: isolate data and audit dependencies
A historical clone creates an independent writable snapshot at a retained point; an isolated environment also requires reviewing permissions and dependencies.
Your learning goal
Create a reproducible historical environment and identify dependencies that could still read, write or trigger activity outside QA.
Understand the idea
A concrete example
A QA view uses a fully qualified production table name. Cloning the surrounding schema does not justify assuming that every SQL string or external path now points to QA.
| Concept | What it means |
|---|---|
| Historical CLONE | Use AT or BEFORE on an eligible retained source. |
| Data isolation | Source and cloned table changes are independent. |
| Dependency isolation | Definitions and external references need separate inspection. |
| COPY GRANTS | An access-control choice, not a safe default for a new QA audience. |
Remember: Validate data, object inventory, definitions, grants and execution state before using or enabling a QA environment.
Explain it step by step · full theory
Learning objectives and prerequisites
Create a reproducible historical environment and identify dependencies that could still read, write or trigger activity outside QA.
Build on Modules 02–04: storage, table types, SELECT, DML and transactions. Module 13 explains why recovery must preserve valid business history. Use the first lesson’s isolated setup; examples name separate demonstration tables so the baseline ORDERS stays unchanged.
A reproducible bug needs a reproducible input
A historical clone is useful when a defect depends on data that no longer exists in current tables. Choose the incident boundary, create a separate schema and clone the required table into it. Keep that baseline read-only for investigators and make another writable clone for experiments.
The source’s full historical timeline does not become the clone’s timeline. Cloning can also combine historical data/name structure with some metadata current at execution; it is not an exact historical capture of every account configuration. Record definitions and settings separately.
Container history can be incomplete or unavailable
A historical database/schema clone must contend with child retention. If a needed current child has insufficient history, the operation can fail. IGNORE TABLES WITH INSUFFICIENT DATA RETENTION can skip such tables, but success then describes an incomplete environment.
Children that did not exist at the chosen time are not part of that old state. The right troubleshooting question is which source identity and child set existed then, not why the clone lacks every object visible today. Prefer a small, explicit recovery scope where possible.
Inspect privileges rather than copying them blindly
For a new table clone, COPY GRANTS carries explicit privileges except OWNERSHIP; the cloning role owns the new table. Without it, explicit source grants are not simply copied, and target future grants can apply. Review SHOW GRANTS on the result and the target schema’s policies.
Container and child grant behavior differs from cloning a single table: child grants can be carried into a container clone while top-level access needs review. Do not grant broad QA access until the actual object inventory, masking/row policies and sensitive data handling are approved.
Dependency checklist before any workload runs
Ordinary views retain SQL definitions; fully qualified references may still read the source. Sequence defaults can remain attached to a source sequence if you clone only its table. Foreign references to policies and objects outside the clone scope can also remain external.
For standard container clones, cloned tasks are suspended by default. Historical schema cloning has task exclusions; do not promise an exact historical task graph. Source-table/stream container clones do not expose the source stream’s previously unconsumed records as a replay backlog. Re-establish and validate CDC deliberately rather than resuming it blindly.
| Object / feature | Review | Reason |
|---|---|---|
| Views / procedure SQL | GET_DDL and fully qualified targets | A SQL reference can still point outside QA |
| Sequences / constraints / policies | Inside vs outside clone scope | References may map to clones or stay with source |
| Tasks / alerts / dynamic tables | Definition, state, owner and compute | Operational activity needs intentional enablement |
| Streams | Offset and intended source | Do not assume the source CDC backlog is copied |
| Stages / pipes | Cloud path, integration and execution state | External storage and credentials are not isolated data copies |
| Tables / clustering | Load history and maintenance state | Load history is not copied; Automatic Clustering starts suspended |
Supported objects are not all objects
The main lab uses ordinary Snowflake-managed tables. External tables are excluded from container cloning; hybrid/Iceberg support has separate scope and restrictions. Internal named stage cloning is opt-in at container scope and is not the same as historical table cloning; table-stage files are not copied with table data.
External stages still point to external locations. New cloned pipes must not be enabled against live ingestion paths without review. Zero-copy data isolation cannot prevent an external side effect caused by an unchanged integration or procedure.
Production decisions and common mistakes
Validate data, object inventory, definitions, grants and execution state before using or enabling a QA environment.
Do not resume all cloned jobs or assume an old snapshot reproduces every old dependency and configuration.
Key takeaways
No. Inventory omitted tables and dependencies, document the missing scope and reconstruct it from approved sources. A successful command does not establish environmental completeness.
Words used in this lesson
- Dependency
- Another object or external service used by a definition.
- COPY GRANTS
- Optional privilege copying; it does not copy ownership for a new table clone.
- Foreign reference
- A reference outside the scope being cloned.
- Historical environment
- A reproducible past data snapshot plus reviewed runtime configuration.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Historical Dev/QA clones: isolate data and audit dependencies
- Before bad DELETE · 4 orders
- Valid later changes remain
Identify a reproducible incident point
Use a known query ID within retention. A historical clone creates a writable investigation environment without rewinding the source.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Identify a reproducible incident point
Use a known query ID within retention. A historical clone creates a writable investigation environment without rewinding the source.
- Incident snapshot: Before bad DELETE · 4 orders
- Current source: Valid later changes remain
- Create a QA container
Clone only the required table into a dedicated QA schema. This avoids silently copying unrelated integrations or operational objects.
- M14_QA: Historical ORDERS
- M14_LAB: Independent current table
- Audit dependencies and privileges
A fully qualified view can still refer to the source. External stage paths still point outside the clone. Inspect grants, definitions and execution targets before enabling any workload.
- Review: GET_DDL; SHOW GRANTS
- External dependencies: Stages / integrations; Sequences / policies
- Promote the fix, not the old database
Reproduce the fault in QA, validate the SQL change, then apply an approved targeted repair. Cloning historical data is not a deployment plan for all production objects.
- QA: Test evidence
- Production plan: Reviewed repair; Preserve valid changes
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Before running this lesson
Manual Snowflake practice only; SQL has not been executed for this course. Use an authorized warehouse and role with access to L2_OBJECTS_LAB and CREATE SCHEMA/CREATE TABLE as needed. Run in M14_LAB, in one session with one writer, using autocommit unless a transaction is shown. Run CREATE once, never replace an existing production object. Standard Edition with one-day retention is sufficient for the main lab; longer retention and administrative monitoring have separate requirements.
Create historical QA input from a known event
Definition: BEFORE excludes the deliberate update in this single-writer example.
When to use: Fresh HIST_SOURCE and M14_QA; permission to create the QA schema is required.
USE SCHEMA L2_OBJECTS_LAB.M14_LAB;
CREATE TABLE HIST_SOURCE CLONE ORDERS;
UPDATE HIST_SOURCE SET AMOUNT=0 WHERE ORDER_ID=101;
SET hist_incident_id=LAST_QUERY_ID();
CREATE SCHEMA L2_OBJECTS_LAB.M14_QA;
USE SCHEMA L2_OBJECTS_LAB.M14_LAB;
CREATE TABLE L2_OBJECTS_LAB.M14_QA.ORDERS CLONE HIST_SOURCE
BEFORE(STATEMENT => $hist_incident_id);
SELECT ORDER_ID,AMOUNT FROM L2_OBJECTS_LAB.M14_QA.ORDERS WHERE ORDER_ID=101;
SELECT ORDER_ID,AMOUNT FROM HIST_SOURCE WHERE ORDER_ID=101;
SHOW GRANTS ON TABLE L2_OBJECTS_LAB.M14_QA.ORDERS;What to expect and why
QA has 101=100 while the current source has 101=0. No grants are copied explicitly by this statement; still inspect target future grants and inherited access.
Demonstrate a reference that still points to source
Definition: A copied view definition can preserve a fully qualified external reference.
When to use: Optional new schema clone; the preceding M14_QA setup is required.
CREATE VIEW L2_OBJECTS_LAB.M14_QA.SOURCE_TOTAL AS
SELECT SUM(AMOUNT) AS TOTAL FROM L2_OBJECTS_LAB.M14_LAB.HIST_SOURCE;
CREATE SCHEMA L2_OBJECTS_LAB.M14_QA_COPY CLONE L2_OBJECTS_LAB.M14_QA;
SELECT GET_DDL('VIEW','L2_OBJECTS_LAB.M14_QA_COPY.SOURCE_TOTAL');
SELECT * FROM L2_OBJECTS_LAB.M14_QA_COPY.SOURCE_TOTAL;
SELECT SUM(AMOUNT) AS QA_TOTAL FROM L2_OBJECTS_LAB.M14_QA_COPY.ORDERS;What to expect and why
The view still reads HIST_SOURCE and returns 400. The cloned historical ORDERS table totals 500. Inspect definitions before treating a container clone as isolated.
Optional historical container template
Definition: Container cloning is broader than copying one table.
When to use: Only with a real retained timestamp for the dedicated source container from the cloning lesson.
-- Replace with a real eligible timestamp; this is a template, not a runnable date.
-- CREATE DATABASE M14_HIST_DATABASE CLONE M14_CONTAINER_SOURCE
-- AT(TIMESTAMP => '<retained UTC timestamp>'::TIMESTAMP_TZ);
-- CREATE SCHEMA L2_OBJECTS_LAB.M14_HIST_SCHEMA CLONE M14_CONTAINER_SOURCE.SALES
-- AT(TIMESTAMP => '<retained UTC timestamp>'::TIMESTAMP_TZ);
-- If using IGNORE TABLES WITH INSUFFICIENT DATA RETENTION,
-- document every omitted table; do not call it a complete recovery.
SELECT GET_DDL('TABLE','L2_OBJECTS_LAB.M14_QA.ORDERS');What to expect and why
The active statement inspects the QA table definition. Historical container templates are optional; every source and relevant child must meet the chosen recovery conditions.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
An old schema clone succeeds with an ignore-insufficient-retention option. Can you call it a complete recovery?
Compare your reasoning
No. Inventory omitted tables and dependencies, document the missing scope and reconstruct it from approved sources. A successful command does not establish environmental completeness.
Key takeaway
Validate data, object inventory, definitions, grants and execution state before using or enabling a QA environment.
Connect this lesson to the learning path
Official sources and curriculum
Module 14 · See module scope
By Rohit Ray · Independent educational lesson · Explore this visual lab