Skip to main content
Exports the data of a table to a specified location. This is an asynchronous operation. The export result is returned after you submit the export task. You can use SHOW EXPORT to view the progress of the export task.
NOTICE You can export data out of tables only as a user who has the EXPORT privilege on those tables. If you do not have the EXPORT privilege, follow the instructions provided in GRANT to grant the EXPORT privilege to the user that you use to connect to your cluster.

Syntax

Parameters

  • table_name The name of the table. The database supports exporting the data of tables whose engine is olap or mysql.
  • partition_name The partitions from which you want to export data. By default, if you do not specify this parameter, the database exports the data from all partitions of the table.
  • column_name The columns from which you want to export data. The sequence of columns that you specify by using this parameter can differ from the schema of the table. By default, if you do not specify this parameter, the database exports the data from all columns of the table.
  • export_path The location to which you want to export the data of the table. If the location contains a path, make sure that the path ends with a slash (/). Otherwise, the part following the last slash (/) in the path will be used as the prefix to the name of the exported file. By default, data_ is used as the file name prefix if no file name prefix is specified.
  • opt_properties Optional properties that you can configure for the export task. Syntax:
  • WITH BROKER In v2.4 and earlier, input WITH BROKER "<broker_name>" to specify the broker you want to use. From v2.5 onwards, you no longer need to specify a broker, but you still need to retain the WITH BROKER keyword.
  • broker_properties The information that is used to authenticate the source data. The authentication information varies depending on the data source. For more information, see BROKER LOAD.

Examples

Export all data of a table to HDFS

The following example exports all data of the testTbl table to the hdfs://<hdfs_host>:<hdfs_port>/a/b/c/ path of an HDFS cluster:

Export the data of specified partitions of a table to HDFS

The following example exports the data of two partitions, p1 and p2, of the testTbl table to the hdfs://<hdfs_host>:<hdfs_port>/a/b/c/ path of an HDFS cluster:

Export all data of a table to HDFS with column separator specified

The following example exports all data of the testTbl table to the hdfs://<hdfs_host>:<hdfs_port>/a/b/c/ path of an HDFS cluster and specifies that commas (,) is used as the column separator:
The following example exports all data of the testTbl table to the hdfs://<hdfs_host>:<hdfs_port>/a/b/c/ path of an HDFS cluster and specifies that \x01 (the default column separator supported by Hive) is used as the column separator:

Export all data of a table to HDFS with file name prefix specified

The following example exports all data of the testTbl table to the hdfs://<hdfs_host>:<hdfs_port>/a/b/c/ path of an HDFS cluster and specifies that testTbl_ is used as the prefix to the name of the exported file:

Export data to AWS S3

The following example exports all data of the testTbl table to the s3-package/export/ path of an AWS S3 bucket: