← Back to Tutorials
19. Unload to Local
COPY INTO Location
-- Export table to stage files
COPY INTO @my_stage/unload/
FROM sales_table
FILE_FORMAT = (TYPE = CSV COMPRESSION = GZIP)
HEADER = TRUE
OVERWRITE = TRUE;
-- Export specific columns
COPY INTO @my_stage/unload/
FROM (SELECT id, name, amount FROM sales_table)
FILE_FORMAT = (TYPE = PARQUET);
-- Download from stage
GET @my_stage/unload/ file://local_output/;
Export Formats
| Format | Use Case |
| CSV | Universal, spreadsheet-compatible |
| JSON | Web applications, APIs |
| Parquet | Columnar, efficient, data pipelines |
| ORC | Hive/Spark compatibility |
Partitioned Export
COPY INTO @my_stage/unload/
FROM sales_table
PARTITION BY ('year=' || YEAR(sale_date))
FILE_FORMAT = (TYPE = PARQUET);
✏️ Exercise: Export a table as CSV with headers, download using GET, and verify file contents.