Skip to main content

EXPORT … INTO

Kinetica can export data from one or more tables, using an EXPORT ... INTO statement. The data can be exported to either of the following:
  • KiFS
  • a data sink configured to allow write access to:
    • remote files on Azure, GCS, HDFS, or S3
    • a writable remote database table via JDBC
For contextualized examples, see Examples. For copy/paste examples, see Exporting Data.
EXPORT ... INTO Syntax
No automatic data type transformations are done between the local data and remote column types. If any transformations are necessary, the QUERY clause should be used and the transformation done within it.

Parameters

TABLE

Source data specification clause, where [<schema name>.]<table name> is the name of the table (and, optionally, its schema) to export into the remote database.
This clause is mutually exclusive with the QUERY clause.

QUERY

Source data specification clause, where <data query> is a SQL SELECT statement to run locally to generate a result set to export into the remote database.
This clause is mutually exclusive with the TABLE clause.

FILE PATH

Target file specification clause, where <file path> is a single-quoted file path to which data will be written.
This clause is mutually exclusive with the REMOTE TABLE & REMOTE QUERY clauses, and is only applicable when exporting to an Azure, GCS, HDFS, or S3 data sink, or to KiFS.
The form of a file path is dependent on the target referenced:
  • Data Sink: If a data sink is specified in the export options this file path must resolve to a writable file/directory at that data sink location. A “path prefix” can be specified, which will cause all files written to begin with that prefix, and an appropriate extension will be appended, based on file format. For example, a “path prefix” of /data/emp for <file path> might result in the following files being written when exporting the employee table multiple times:
    • /data/emp/employee_123450000.csv
    • /data/emp/employee_123460000.csv
    • /data/emp/employee_123480000.csv
    If using an HDFS data sink, the “path prefix” must be the name of an HDFS directory.
  • KiFS: The path must resolve to a writable file path within KiFS. A “path prefix” can be specified, which will cause all files written to begin with that prefix, and an appropriate extension will be appended, based on file format. For example, a “path prefix” of /data/emp for <file path> might result in the following files being written when exporting the employee table multiple times:
    • kifs://data/emp/employee_123450000.csv
    • kifs://data/emp/employee_123460000.csv
    • kifs://data/emp/employee_123480000.csv
The SINGLE_FILE option can be used to create one file with no suffix appended to the base file name, or to create multiple smaller files to increase the export performance.

FORMAT

Optional indicator of target file type; default is DELIMITED TEXT.Supported formats include:
KeywordDescription
[DELIMITED] TEXTA text-based, delimited field data file (CSV, PSV, TSV, etc.); a comma-delimited list of options can be given to specify the way in which the data file(s) should be written, including the delimiter used, whether headers are present, etc. Records spanning multiple lines are not supported.
Non-numeric fields will be double-quoted, and double quotes in the data will be escaped with two double quotes. See Delimited Text Options for the complete list of <delimited text options>.
PARQUETApache Parquet data file

REMOTE TABLE

Target table specification clause, where [<schema name>.]<table name> is the name of the table (and, optionally, its schema) in the remote database into which data will be exported.Data will be exported using an INSERT statement of the form:
This default form can be modified to use the ? parameter form via the USE_INDEXED_PARAMETERS option.
This clause is mutually exclusive with the FILE PATH & REMOTE QUERY clauses.

REMOTE QUERY

Target insert specification clause, where <insert statement> is a SQL INSERT statement defining the way in which data will be loaded into the remote database. The target table named in the INSERT statement must already exist in the remote database.
This clause is mutually exclusive with the FILE PATH & REMOTE TABLE clauses.

WITH OPTIONS

Optional indicator that a comma-delimited list of connection & global option/value assignments will follow.See Export Options for the complete list of options.

Delimited Text Options

The following options can be specified when exporting data into delimited text files.

DELIMITER = '<char>'

Use char as the target file field delimiter.The default delimiter is a comma, unless the target file has one of these extensions:
  • .psv - will cause | to be the delimiter
  • .tsv - will cause the tab character to be the delimiter
Since non-numeric fields are automatically double-quoted when written out, it is not recommended to use a double quote character as the delimiter.
See Delimited Text Option Characters for allowed characters.

HEADER DELIMITER = '<char>'

Use char as the target file header field name/property delimiter, when writing the header in Kinetica custom format (when KINETICA_HEADER is TRUE).The default is the | (pipe) character. See Delimited Text Option Characters for allowed characters.
The DELIMITER character will still be used to separate field name/property sets from each other in the header row

INCLUDES HEADER = <TRUE|FALSE>

Declare that the target file(s) will or will not have a header.The default is TRUE.

KINETICA_HEADER = <TRUE|FALSE>

Declare that the target file(s) will or will not have a custom Kinetica header.The default is FALSE.In the custom Kinetica format, each field’s header contains the field name and any associated column properties delimited by a different character than the one used to separate field values.An example Kinetica header in a CSV file:

NULL = '<string>'

Treat string as the indicator of a null field value.The default is the empty string.

Delimited Text Option Characters

For DELIMITER & HEADER DELIMITER, any single character can be used, or any one of the following escaped characters: For instance, specifying \t for DELIMITER will cause the target files to be written with ASCII horizontal tab characters as delimiter characters.

Export Options

The following options can be specified to modify the way data is written to the target. Which options apply to which target types is noted below.

Examples

Export Table to File (KiFS)

To export a table of employees to a file in KiFS:
EXPORT ... INTO (File from Table) Example

Export Query to File (KiFS)

To export a query of employees in department 2 to a Parquet file in KiFS:
EXPORT ... INTO (File from Query) Example

Export Table via Data Sink

To export a table of employees through the JDBC data sink jdbc_dsink, into a remote database table named example.remote_employee:
EXPORT ... INTO (Data Sink Table from Table) Example

Export Table via Data Sink DML

To export a table of employees through the JDBC data sink jdbc_dsink, into a remote database table named example.remote_employee, using a custom INSERT statement:
EXPORT ... INTO (Data Sink DML from Table) Example

Export Query via Data Sink DML

To export a query of employees in department 2 through the JDBC data sink jdbc_dsink, into a remote database table named example.remote_employee_dept2, using a custom INSERT statement:
EXPORT ... INTO (Data Sink DML from Query) Example