Zero Copy Cloning in snowflake cloud data warehouse

What is Zero-Copy Cloning: 

Snowflake cloning is a meta data-only related operation only, there is no physical data copied from one environment to another, clone data point out to  the actual database and further CRUD operations keep separately in new environment which do not effect the old data,  it is important to note that there is no data movement during a clone operation, only creation of new meta data. The meta data for these new database objects simply point back to the original source data. There is no additional cost when creating a clone. You will incur the cost of storage when DML ops is applied to the cloned data.



Create a clone of the table:

CREATE OR REPLACE TABLE demo_db.public.employees_clone CLONE employees;

 

Create a clone of the database:

 

CREATE or replace DATABASE demo_db_clone CLONE demo_db;

 

Clone objects are writable and is independent from clone source database, changes made on either cloned object or source object are not a part of other. ðŸ˜Š interesting. This makes clone very easy and without any cost.

There are some restrictions while cloning of objects or databases:

Ø  Network policy, Resource Monitor , Warehouse Objects and other Account level objects are out of scope during cloning operations.

Ø  The database level grants are not inherited from the source databases, they are reset with the ownership privileges.

Ø  Table objects in a clone that utilizes SEQUENCE objects are not automatically updated to reference cloned objects. You will need to manually update these references in the cloud database as follows:


Alter table test
Alter column <sequence> set default clone_db.clone_schema.original_sequencename.nextval

 

Ø  Pipe and Internal stages can not be cloned

 

It is highly recommended that such objects are scripted and ideally version controlled so that they can be easily ported and reused.



Regards,

Vidit - A data scientist in snowflake data warehouse  

Comments

Popular posts from this blog

error_on_column_count_mismatch=false : Number of columns in file does not match that of the corresponding table use file format option error_on_column_count_mismatch=false to ignore this error File

Practice Set 1: Snowpro Certification Practice Set with more than 250 Unique Questions

Snowflake Automation using SnowSql CLI || Create Azure Devops CI CD using Snowsql CLI