Unloading data from Snowflake tables
Similar to data loading, Snowflake supports bulk export (i.e. unload) of data from a database table into flat, delimited text files.
First, Set the Context:
USE WAREHOUSE TRAINING_WH;
USE DATABASE SALES_NAVEEN_DB;
USE SCHEMA SALES_DATA;
For the purpose of this tutorial let us create a temporary sales table, from where we can unload the data
CREATE TABLE SALES_NAVEEN_DB.SALES_DATA.SALES AS select * from snowflake_sample_data.TPCDS_SF100TCL.STORE_SALES LIMIT 1000;
Create a named stage:
create stage my_unload_stage;
Unload the table into a file in the named stage:
copy into @my_unload_stage
from (select * from SALES_NAVEEN_DB.SALES_DATA.SALES)
file_format = (type = csv field_optionally_enclosed_by='"');
List the files to make sure the export was successful
list @my_unload_stage;
Finally, download the files to our local system:
get @my_unload_stage file://C:\Users\Naveen\Desktop\unload;
Post Comment