COPY INTO is Snowflake's core command for data loading and unloading. A single command handles bulk loads from a stage into a table and exports from a table back out to a stage, and its rich options — FILE FORMAT, ON_ERROR, and VALIDATION_MODE — give you the flexibility to build production-grade data pipelines.
On the SnowPro Core exam, COPY INTO falls under Domain 4 (Data Loading & Unloading, 10-15% of the exam). The Data Engineer exam goes even deeper into its options. This article organizes COPY INTO end-to-end from a practical design perspective and highlights the points that come up most often on the exams.
The basic syntax for loading data from a stage into a table:
COPY INTO <table_name>
FROM @<stage_name>/<path>/
FILE_FORMAT = (FORMAT_NAME = '<file_format_name>'
| TYPE = CSV | JSON | PARQUET | AVRO | ORC | XML)
PATTERN = '.*\.csv\.gz'
ON_ERROR = ABORT_STATEMENT | CONTINUE | SKIP_FILE | SKIP_FILE_<N>
PURGE = TRUE | FALSE
FORCE = TRUE | FALSE;| Parameter | Default | Description |
|---|---|---|
| FILE_FORMAT | CSV | Specifies the file format. Use a named FILE FORMAT or an inline definition. |
| PATTERN | (none) | Regex to filter which files get loaded |
| ON_ERROR | ABORT_STATEMENT | Behavior when an error occurs. CONTINUE and SKIP_FILE are also available. |
| PURGE | FALSE | When TRUE, files in the stage are auto-deleted after a successful load. |
| FORCE | FALSE | When TRUE, files already loaded within the last 64 days will be re-loaded. |
| VALIDATION_MODE | (none) | Dry run. RETURN_ERRORS / RETURN_ALL_ERRORS / RETURN_N_ROWS. |
By default, COPY INTO keeps 64 days of load-history metadata and automatically prevents the same file from being loaded twice. When a file's path, size, and last-modified timestamp match the metadata, the file is skipped. You can override this with FORCE = TRUE, but the best practice is to leave duplicate prevention enabled in production.
The syntax for exporting data from a table out to a stage:
COPY INTO @<stage_name>/<path>/
FROM <table_name> | (<SELECT statement>)
FILE_FORMAT = (TYPE = CSV | JSON | PARQUET)
SINGLE = TRUE | FALSE
MAX_FILE_SIZE = <bytes>
HEADER = TRUE | FALSE
OVERWRITE = TRUE | FALSE;| Parameter | Default | Description |
|---|---|---|
| SINGLE | FALSE | TRUE writes to a single consolidated file; FALSE writes parallel split files. |
| MAX_FILE_SIZE | 16MB | Maximum size per file when writing split output |
| HEADER | FALSE | When TRUE, includes a CSV header row in the output. |
| OVERWRITE | FALSE | When TRUE, overwrites existing files in the stage. |
The FROM clause on unload accepts a SELECT statement directly, so you can export filtered, aggregated, or transformed results rather than the entire table.
FILE FORMAT is an object that defines a data format and its parsing rules. By creating a named FILE FORMAT up front, you avoid restating the options in every COPY INTO statement.
CREATE FILE FORMAT my_csv_format
TYPE = CSV
FIELD_DELIMITER = ','
RECORD_DELIMITER = '\n'
SKIP_HEADER = 1
FIELD_OPTIONALLY_ENCLOSED_BY = '"'
NULL_IF = ('NULL', 'null', '')
EMPTY_FIELD_AS_NULL = TRUE
COMPRESSION = GZIP;| Format | Primary Use Case | Load | Unload | Notes |
|---|---|---|---|---|
| CSV | General-purpose text data | Yes | Yes | SKIP_HEADER and FIELD_DELIMITER matter most |
| JSON | Semi-structured data | Yes | Yes | STRIP_OUTER_ARRAY and STRIP_NULL_VALUES come up often |
| Parquet | Columnar analytics data | Yes | Yes | Defaults to SNAPPY compression |
| Avro | Binary with schema | Yes | Yes | Supports schema evolution |
| ORC | Hadoop interoperability | Yes | No | Load only |
| XML | Legacy system integration | Yes | No | Load only |
ON_ERROR is the key parameter that defines your error-handling strategy on data load.
| ON_ERROR value | Behavior | Recommended Use |
|---|---|---|
| ABORT_STATEMENT (default) | A single error row rolls back the entire load | Production loads of pre-validated data |
| CONTINUE | Skip error rows and load only valid rows | External data with inconsistent quality |
| SKIP_FILE | Skip any file that contains errors | Bulk loads across many files |
| SKIP_FILE_<N> | Skip only files with N or more error rows | Filter by a fixed quality threshold |
| SKIP_FILE_<N>% | Skip only files where the error rate is N% or higher | Percentage-based quality filtering |
When you use ON_ERROR = CONTINUE, the details of skipped error rows can be inspected after the fact with the VALIDATE function. SELECT * FROM TABLE(VALIDATE(my_table, JOB_ID => '_last')) returns the error rows from the most recent COPY INTO.
When VALIDATION_MODE is set, no data is loaded — Snowflake returns only the file validation results. It's a must-have for pre-flight checks before a production load.
| Mode | Behavior | Use Case |
|---|---|---|
| RETURN_<N>_ROWS | Validates the first N rows and returns the results | Sanity-check file format behavior |
| RETURN_ERRORS | Returns only error rows (subject to a max-file limit) | Quality check before a production load |
| RETURN_ALL_ERRORS | Returns every error row across every file | Generate a comprehensive quality report |
COPY INTO my_table
FROM @my_stage/data/
FILE_FORMAT = (FORMAT_NAME = 'my_csv_format')
VALIDATION_MODE = 'RETURN_ERRORS';| Stage Type | Managed By | Sharing | Use Case |
|---|---|---|---|
| User stage (@~) | Snowflake | Owner only | Personal scratch space for files |
| Table stage (@%table) | Snowflake | Per table | Dedicated to loading a specific table |
| Named internal stage | Snowflake | Controlled by role | Team-shared file management |
| External stage (S3/Azure/GCS) | Cloud provider | Controlled by IAM | Integration with existing cloud storage |
Inlining format options in every COPY INTO statement quickly becomes unmaintainable. Use CREATE FILE FORMAT to create a named object and reference it from COPY INTO with FORMAT_NAME. When the format needs to change, editing the FILE FORMAT object in one place propagates the change to every COPY INTO statement.
Especially for data whose quality you don't control — like CSVs received from external partners — run VALIDATION_MODE = 'RETURN_ERRORS' as a pre-check. It surfaces file format mismatches, data type errors, and NULL constraint violations before the production load runs.
Leaving loaded files behind in a stage accumulates storage cost and slows down file listing on subsequent COPY INTO runs. Either set PURGE = TRUE to auto-delete loaded files or run REMOVE @stage on a regular schedule.
Snowflake's documentation recommends 100-250 MB compressed as the sweet spot for COPY INTO file sizes. Files that are too small (a few KB to a few MB) carry too much overhead; files that are too large (over 1 GB) hurt parallel processing efficiency.
SnowPro Core - Data Loading
問題 1
Which statement correctly describes the behavior of COPY INTO when ON_ERROR = 'CONTINUE' is set?
正解: B
With ON_ERROR = 'CONTINUE', any row that errors out (row-level data type errors, NULL constraint violations, etc.) is skipped, and only the valid rows are loaded into the table (B is correct). Option A describes ON_ERROR = 'ABORT_STATEMENT' (the default). Option C describes ON_ERROR = 'SKIP_FILE', which skips at the file level. The behavior in option D — loading every row including error rows — does not exist for any ON_ERROR option. Details of rows skipped under CONTINUE can be reviewed after the fact via the VALIDATE function: SELECT * FROM TABLE(VALIDATE(table, JOB_ID => '_last')).
When should I use COPY INTO vs Snowpipe?
Use COPY INTO for batch loads of file sets, and Snowpipe to auto-load files as soon as they land in a stage. COPY INTO uses Virtual Warehouse compute and gives you explicit control over execution timing. Snowpipe runs on serverless compute and is triggered automatically by cloud storage event notifications (S3: SQS / Azure: Event Grid / GCP: Pub/Sub). COPY INTO fits daily batch loads; Snowpipe fits near-real-time continuous ingestion. On cost, COPY INTO is better for large files loaded infrequently, while Snowpipe is better for small files loaded frequently.
Which ON_ERROR option should I choose?
The right ON_ERROR option depends on data quality requirements and business impact. For initial production loads or pre-validated data, use ABORT_STATEMENT (the default): a single error row rolls back the entire load, guaranteeing data integrity. For data with inconsistent quality (such as CSVs from external partners), use CONTINUE to skip error rows and post-process them after the load. SKIP_FILE works well for bulk loading many files at once — files containing errors are skipped while clean files load. SKIP_FILE_<N> and SKIP_FILE_<N>% let you set an error tolerance threshold.
What is VALIDATION_MODE?
VALIDATION_MODE is COPY INTO's dry-run feature: it validates files without actually loading any data. It has three modes — RETURN_<N>_ROWS (returns the first N rows), RETURN_ERRORS (returns only error rows), and RETURN_ALL_ERRORS (returns every error row across all files). The best practice is to run VALIDATION_MODE = 'RETURN_ERRORS' before a production load to catch file format mismatches and data type errors up front. When VALIDATION_MODE is set, no data is loaded at all, so you can test safely.
Practice more COPY INTO questions
Sharpen your COPY INTO knowledge with questions from the Data Loading & Unloading domain.
Try free questions →Related Snowflake Data Loading Articles
Snowpipe: Complete Guide
How automatic data loading works and how to set it up
Designing Snowflake Stages
When to use internal vs. external stages and how to design them
Working with Semi-Structured Data
Using the VARIANT type, FLATTEN, and colon notation
80 Essential Snowflake Terms
Key exam terms organized by category
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Snowflake Certifications: All 11 Exams Explained (2026)
Every SnowPro certification — Associate, Core, Specialty, Ad...
Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)
All 11 SnowPro exams ranked by difficulty with study-time es...
Snowflake Study Guide: Fastest Pass Route by Exam (2026)
How to pass SnowPro certifications efficiently — official ma...
SnowPro Core (COF-C03): Complete Exam Guide (2026)
Pass the SnowPro Core exam — six domains, scope, sample ques...
SnowPro Associate Platform (SOL-C01): Complete Guide (2026)
The entry-level SnowPro Associate exam — scope, weighting, s...