To use the data extract tool, you must have JDBC version 2.63 or higher.
Supported Data Extract Formats
The data extract tool supports unloading result sets into files in specific formats. Supported extract formats are:- CSV — Outputs result sets as text files with fields separated by a chosen delimiter.
- Parquet — Outputs result sets as Parquet files.
General Command Structure
Here is the general structure of an extract command.SQL
EXTRACT TO. The location type location_type must be either LOCAL for the local machine or S3 for S3. You can enclose additional options within a pair of parentheses following the keyword OPTIONS. The location type is required and there are required options for each location type. For the LOCAL location type, the options must define the file prefix file_prefix, and for S3, the options must define the file prefix file_prefix, bucket bucket, and endpoint endpoint. Next, the query follows the keyword AS.
This example is a simple general command structure.
SQL
Specify Options, Quoting, and Escaping Quotes
Here is the general format of options.SQL
") or unquoted. If values are unquoted, they can only contain alphanumeric characters. If the value has a non-alphanumeric character, you must quote it with the reserved character ". Note that the single quote character does not work.
SQL
" as an argument, you must escape it with the backslash character \. To use \ as an argument, you must escape it with another \. This code illustrates both of these scenarios.
SQL
Data Extract Options
Use these optional options with theEXTRACT TO syntax and the OPTIONS keyword to configure the behavior of the extract.
General Extract Options
This table describes optional options that apply to both theLOCAL and S3 location types.
If you do not set either the
MAX_ROWS_PER_FILE or the TARGET_FILE_SIZE_MB options, the data extract tool generates one output file for each partition. For a query without partitions, the tool generates a single output file.S3 Extract Options
This table describes the required options that apply only to theS3 location type. The data extract tool ignores these options when you use the LOCAL location type.
This table describes optional options that apply only to the
S3 location type.
File Naming Conventions
When you use the data extract tool, the tool produces a number of files. The System determines the path of these files using multiple factors:- File prefix as specified by the
FILE_PREFIXoption- If the
PARTITION_MODEoption is not set toNONE, the file prefix must be a directory and end with a forward slash. The system creates subdirectories in the style for each partition (for example, for theKEYpartition:/tmp/extract/col1=val1/col2=val2or for theRANGEpartition:/tmp/extract/val1<=col1<val2/). If thePARTITION_MODEoption is set toNONE, the file prefix can be a directory or a proper prefix (for example,/tmp/extract/results_).
- If the
- Partition mode as specified by the
PARTITION_MODEoption - Maximum number of rows, or target size in MB, for each file as specified by the
MAX_ROWS_PER_FILEoption- If you do not set a maximum number of rows per file and no target file size, this part of the convention is
0. However, if theMAX_ROWS_PER_FILEorTARGET_FILE_SIZE_MBoptions are set, then the system outputs rows to a single file until that limit or the lower of the two limits is reached. Then, the system generates another file with an incremented file number. The file number starts from0.
- If you do not set a maximum number of rows per file and no target file size, this part of the convention is
- Format or file extension
- This convention applies only if the
FILE_TYPEoption is set toDELIMITED. For thePARQUETtype, the file extension is always.parquet, even when you specify any type of compression using thePARQUET_COMPRESSIONoption.
- This convention applies only if the
- Compression extension
- If you specify the
COMPRESSIONoption for an extract with theDELIMITEDtype, then the tool adds the compression suffix.
- If you specify the
Examples
These examples show you how to use the data extract tool for extracting data to the local machine, extracting CSV data, and extracting Parquet data. Most of these examples assume the database already contains tables with data. For loading data, see Load Data. Local Extract to the Default Path This example extracts the results of theSELECT c1 FROM sys.dummy10 SQL query to the local machine at the relative path result-0.csv. The SQL query returns 10 rows with incremental numbers starting at 1. The OPTIONS(...) syntax is only required when you specify additional options.
SQL
sys.dummy creates a virtual table with the specified number for rows. For details, see Generate Tables Using sys.dummy.SELECT c1 FROM sys.dummy10 SQL query to the local machine at the absolute path /home/user/out/data_0.csv. The SQL query returns 10 rows with incremental numbers starting at 1.
SQL
country column. This partitioning creates a Hive-style directory structure on the local machine. Use the file path /home/user/customer_data/ with the KEY value for the partition strategy. Specify the target file size to be 256 MB.
The SQL query selects the identifier, name, email, and country from the customers table.
SQL
today_sales table to a single Parquet file on S3 using ZSTD compression. Use the S3 bucket named my-analytics-bucket with the file path daily_reports/report.parquet using the endpoint s3.us-east-1.amazonaws.com.
SQL
event_id column into 30 parallel queries using the RANGE partition strategy. Specify the maximum file size in 1024 megabytes. Override the default row group size using the PARQUET_ROW_GROUP_SIZE_BYTES option to specify 268435456 bytes (256 MB).
Use the S3 bucket iot-data with the file path events/2025-09-25/ at endpoint s3.us-east-1.amazonaws.com.
The SQL query selects the event identifier, sensor identifier, sensor reading, and timestamp from the events table.
SQL

