How to Export a Snowflake Table to CSV

Galaxy Glossary

How do I export a Snowflake table to CSV with COPY INTO?

COPY INTO lets you quickly dump any Snowflake table or query result set to one or many CSV files in an internal or external stage.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

How do I quickly dump a table to CSV?

Run a single COPY INTO command that writes the table’s rows into CSV files on a stage you control. No GUI clicks, no intermediate scripts.

-- one-liner
COPY INTO @my_stage/orders_ FROM Orders FILE_FORMAT = (TYPE = CSV);

What syntax does COPY INTO use?

COPY INTO <stage_path> FROM <table|select> [FILE_FORMAT=(...)] [HEADER=TRUE] [OVERWRITE=TRUE]. The stage can be @~/ (user), @my_int_stage, or s3://bucket/ if an external stage is mapped.

Key, optional parameters

  • FILE_FORMAT – inline or named.Controls delimiter, compression, null handling.
  • HEADER – write column names as first row (TRUE|FALSE).
  • SINGLE – produce exactly one file (good for small tables).
  • OVERWRITE – replace existing files.

How can I export only recent data?

Wrap a SELECT in parentheses. Example: last-30-days orders.

COPY INTO @my_stage/orders_recent_
FROM (SELECT * FROM Orders WHERE order_date >= CURRENT_DATE - 30)
FILE_FORMAT=(TYPE=CSV FIELD_DELIMITER=',' NULL_IF=('NULL')) HEADER=TRUE SINGLE=TRUE;

Where do the files go?

If you use a user or internal stage, download via SnowSQL: !get @my_stage/orders_ file:///tmp/.For S3 stages, the files already sit in the bucket.

Best practices for reliable exports

  • Create a named file format so multiple teams export identically.
  • Include HEADER=TRUE for self-describing files.
  • Use SINGLE=TRUE for small tables; skip it for big data to parallelise.

Common mistakes and fixes

Forgetting a stage path

Wrong: COPY INTO Orders .... Always point to a stage, e.g., @~/orders_.

Exporting huge tables with SINGLE=TRUE

Generates one massive file and slows export.Remove SINGLE or set to FALSE so Snowflake shards output.

FAQ

Can I automate daily exports?

Yes—wrap COPY INTO in a Task scheduled daily. Store files in an external S3 stage for downstream systems.

How do I include column headers?

Add HEADER=TRUE to the command or define it inside a named file format.

.

Why How to Export a Snowflake Table to CSV is important

How to Export a Snowflake Table to CSV Example Usage


-- Export Orders with line items to S3 stage in parallel files
COPY INTO @sales_exports/orders_full/
FROM (
  SELECT o.id, o.customer_id, o.order_date, o.total_amount,
         i.product_id, i.quantity,
         p.name AS product_name, p.price
  FROM Orders o
  JOIN OrderItems i ON i.order_id = o.id
  JOIN Products   p ON p.id = i.product_id
)
FILE_FORMAT = (TYPE = CSV COMPRESSION = GZIP)
HEADER = TRUE;

How to Export a Snowflake Table to CSV Syntax


COPY INTO <stage_path> 
FROM <table_name | (SELECT ...)> 
[FILE_FORMAT = ( 
    TYPE = CSV,               -- CSV, TSV, etc.
    FIELD_DELIMITER = ',',    -- default ','
    COMPRESSION = 'GZIP',     -- NONE|GZIP|BZ2
    NULL_IF = ('NULL')
)]
[HEADER = TRUE | FALSE]
[SINGLE = TRUE | FALSE]
[OVERWRITE = TRUE]

-- Example: dump entire Orders table to a user stage
COPY INTO @~/orders_
FROM Orders
FILE_FORMAT = (TYPE = CSV FIELD_DELIMITER = ',' HEADER = TRUE)
OVERWRITE = TRUE;

Common Mistakes

Frequently Asked Questions (FAQs)

Does COPY INTO lock the table?

No. COPY INTO reads from the micro-partitions without blocking DML.

Can I export to my local disk directly?

Not directly. First copy to an internal stage, then pull files down with SnowSQL or any compatible client.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.