Snowflake features · 5 min read

Snowflake's Zero Copy Cloning

Copy tables, schemas and databases in moments, without physically duplicating the data or paying for extra storage.

What is Snowflake Zero Copy Cloning?

Zero Copy Cloning is a Snowflake feature that lets you create copies of data without physically duplicating the data in the database. Traditionally, if users needed to access data as it was at a given point in time, they would create several development environments. Running multiple development environments can be costly and time-consuming for a business, especially with larger databases.

Zero Copy Cloning clones the data without long delays and without additional cost. Because the data isn't physically copied, no storage fees are charged, and cloning takes far less time than creating a copy of a table from an existing table.

How does it work?

Micro-partitions are Snowflake's units of storage. They hold the data stored in tables, and each time a table changes, the structure of its micro-partitions changes.

Zero Copy Cloning is a metadata operation: it uses the existing micro-partitions to clone the data. It is quick because the data already exists, and the clone simply references the same micro-partitions as the original table.

You can clone:

Databases Schemas Tables Streams Stages File formats Sequences and more

Understanding your Zero Copy Cloning procedure

Once data is cloned, a change made to either the source table or the clone only affects the side it was made on. Changing one does not change the other.

Keep in mind

  • When changes are made, new micro-partitions are created, so additional storage costs apply.
  • If Time Travel is active on your account, the data can be restored within your Time Travel period (for operations such as insert, update and delete).
  • Privileges are not inherited when you clone a single table. If you clone an entire database or schema, the clone does inherit those privileges.

Syntax

CREATE TABLE clone_table_name CLONE source_table_name;
clone_table_name
The name of the new table that the clone creates.
source_table_name
The source table you want to base the new clone on.

SQL

DROP DATABASE CLONE_TEST_DB;

-- create a sample database
CREATE OR REPLACE DATABASE CLONE_TEST_DB;
USE DATABASE CLONE_TEST_DB;

-- create a table based on a table from another schema.
CREATE TABLE CLONE_TEST_DB.PUBLIC.ORDERS
AS SELECT * FROM SNOWFLAKE_SAMPLE_DATA.TPCH_SF10.ORDERS;

-- counting the number of records
SELECT COUNT(*) FROM CLONE_TEST_DB.PUBLIC.ORDERS;

-- CLONE OPERATION
CREATE TABLE ORDERS_CLONE_TABLE CLONE CLONE_TEST_DB.PUBLIC.ORDERS;

-- counting the number of records in the cloned table
SELECT COUNT (*) FROM CLONE_TEST_DB.PUBLIC.ORDERS_CLONE_TABLE;

Demonstration

To see Zero Copy Cloning in practice, watch the demonstration: how the SQL is written, what the clone operation involves, and the results.

Zero Copy Cloning demonstrationOpens on YouTube in a new tab

In this article we looked at Snowflake's Zero Copy Cloning feature, how it works and where you might use it. We hope it gives you the skills and confidence to clone your data and save time in the process.

Need help getting more from Snowflake?

We can help you set up Snowflake and use it well.

Request a Demo