COPY ( <SELECT statement> ) TO '<file path>' [WITH (<property> = value, ...)];
<file path>must be a path on the server. This command exports the results of any SELECT statement to the file. There is a special mode when
<file path>is empty. In that case, the server automatically generates a file in
<OmniSci Directory>/omnisci_exportthat is the client session id with the suffix
Available properties in the optional WITH clause are described in the following table.
Define how to export with arrays that have null elements:
Applies only to GeoJSON and GeoJSONL files.
A single-character string for the delimiter between column values; most commonly:
Other delimiters include
Applies to only CSV and tab-delimited files.
Note: OmniSci does not use file extensions to determine the delimiter.
A single-character string for escaping quotes. Applies to only CSV and tab-delimited files.
File compression; can be one of the following:
For GeoJSON and GeoJSONL files, using GZip results in a compressed single file with a .gz extension. No other compression options are currently available.
Type of file to export; can be one of the following:
For all file types except CSV, exactly one geo column (POINT, LINESTRING, POLYGON or MULTIPOLYGON) must be projected in the query. CSV exports can contain zero or any number of geo columns, exported as WKT strings.
Export of array columns to shapefiles is not supported.
A layer name for the geo layer in the file. If unspecified, the stem of the given filename is used, without path or extension.
Applies to all file types except CSV.
Stem of the filename, if unspecified
A single-character string for terminating each line. Applies to only CSV and tab-delimited files.
A string pattern indicating that a field is NULL. Applies to only CSV and tab-delimited files.
An empty string,
A single-character string for quoting a column value. Applies to only CSV and tab-delimited files.
When using the
COPY TOcommand, you might encounter the following error:
Query couldn’t keep the entire working set of columns in GPU Memory.
To avoid this error, use the
\cputo put your OmniSci server in CPU mode before using the
COPY TOcommand. See Configuration.
COPY (SELECT * FROM tweets) TO '/tmp/tweets.csv';
COPY (SELECT * tweets ORDER BY tweet_time LIMIT 10000) TO
'/tmp/tweets.tsv' WITH (delimiter = '\t', quoted = 'true', header = 'false');