COPY INTO Command — Complete Guide with All Options
Welcome back to RetailCo, our fictional retail company.
Alice, the data engineer, now has staged data files and needs to load them into Snowflake tables efficiently.
“The COPY INTO command is like a magic wand — it moves data from your stage into tables safely and quickly,” she explains.
Let’s explore how COPY INTO works, all its options, and real-world use cases.
🏗️ What Is COPY INTO?
The COPY INTO command loads data from a stage (internal or external) into a Snowflake table.
Basic syntax:
COPY INTO <table_name>
FROM <stage_name>
FILE_FORMAT = (TYPE = CSV)
ON_ERROR = 'CONTINUE';
<table_name>→ destination table<stage_name>→ internal or external stageFILE_FORMAT→ CSV, JSON, Parquet, etc.ON_ERROR→ what to do if errors occur
🔹 Key Options
1️⃣ FILE_FORMAT
Specifies how Snowflake interprets files:
FILE_FORMAT = (TYPE = CSV FIELD_OPTIONALLY_ENCLOSED_BY='"' SKIP_HEADER=1)
Other formats: JSON, PARQUET, ORC.
2️⃣ ON_ERROR
Controls error handling:
| Option | Behavior |
|---|---|
| CONTINUE | Skip bad files/rows, continue loading |
| ABORT_STATEMENT | Stop the load if an error occurs (default) |
| SKIP_FILE | Skip the entire file if an error occurs |
RetailCo example: Alice uses ON_ERROR='CONTINUE' to skip malformed CSV rows while loading daily sales.