All Products
Search
Document Center

AnalyticDB:Asynchronously submit an export job

Last Updated:Mar 28, 2026

INSERT INTO and INSERT OVERWRITE INTO SELECT export data synchronously by default. For large datasets in the hundreds of gigabytes, the connection between your client and the AnalyticDB for MySQL server may time out before the export completes. Submit export tasks asynchronously to avoid this issue.

Submit an export task

Syntax

Basic syntax:

SUBMIT JOB INSERT OVERWRITE table_name select_statement;

To track a task by name instead of ID, specify an alias:

SUBMIT JOB <job_alias_name> AS <query_body>;

Alias constraints:

ConstraintRule
UniquenessMust be unique within the system
FormatPlain string — do not enclose in single or double quotation marks
Character setLetters, digits, and underscores only
Max length128 characters

Set task priority

Available in version 3.1.3.6 and later. Add the /*+async_job_priority=n*/ hint before the SQL statement to control scheduling order. The default priority is 1. Higher values are scheduled first.

/*+async_job_priority=10*/ SUBMIT JOB INSERT OVERWRITE test SELECT * FROM test_external_table;

Examples

Submit a task:

SUBMIT JOB INSERT OVERWRITE test SELECT * FROM test_external_table;

The statement returns a job ID. Save this ID — you can use it to query or cancel the task later.

+---------------------------------------+
| job_id                                |
+---------------------------------------+
| 2017112122202917203100908203303000715 |

Submit a task with an alias:

-- Correct
SUBMIT JOB test_123 AS INSERT INTO test SELECT * FROM test_external_table;

Do not enclose the alias in quotation marks:

-- Incorrect: alias in single quotes
SUBMIT JOB 'test_123' AS INSERT INTO test SELECT * FROM test_external_table;

-- Incorrect: alias in double quotes
SUBMIT JOB "test_123" AS INSERT INTO test SELECT * FROM test_external_table;

Check task status

Syntax

Query by job ID:

SHOW JOB STATUS WHERE job_id='job_id';

Query by alias:

SHOW JOB STATUS WHERE job_name='job_alias_name';

Example

SHOW JOB STATUS WHERE job_id='2017112122202917203100908203303000715';

Example output:

+-------------------------------------------+-------------+-----------+--------------+-----------+----------+-------------------------+-------------------------+---------------------------------------------------+-------------------------------------------+------------+----------+------------+-------------+------------+------------------+------------------------+
| job_id                                    | schema_name | status    | process_rows | fail_rows | fail_msg | create_time             | update_time             | definition                                        | exec_job_id                               | total_rows | progress | start_time | result_rows | result_url | query_priority   | user_define_job_name   |
+-------------------------------------------+-------------+-----------+--------------+-----------+----------+-------------------------+-------------------------+---------------------------------------------------+-------------------------------------------+------------+----------+------------+-------------+------------+------------------+------------------------+
| 2026022710213902101709304503151000743     | test_db     | SUCCEEDED |            4 |         0 | NULL     | 2026-02-27 10:21:39.0   | 2026-02-27 10:21:45.0   | INSERT INTO test SELECT * FROM test_external_table| 2026022710214402101706516803151005717     |          0 | NULL     | NULL       |           0 | NULL       | NORMAL           | test_123               |
+-------------------------------------------+-------------+-----------+--------------+-----------+----------+-------------------------+-------------------------+---------------------------------------------------+-------------------------------------------+------------+----------+------------+-------------+------------+------------------+------------------------+
Note

Returned fields vary by cluster version. Parse task status using the status field.

Task statuses

The status field values differ between cluster editions.

Status (Data Warehouse Edition)Status (Data Lakehouse Edition)Meaning
INITSUBMITTINGTask submitted, waiting to be scheduled.
SUBMITTED / RUNNINGRUNNINGTask is running.
FINISHSUCCEEDEDTask completed successfully. No action required.
FAILEDFAILEDTask failed. Check fail_msg for the error details, then retry or fix the SQL.
NoneCANCELLEDTask was cancelled before or after execution.
Note

CANCELLED is a new state available in Data Lakehouse Edition only. It is not present in Data Warehouse Edition (V3.0).

Cancel a task

Warning

Cancelling a running task may cause imported data to be rolled back. Delete any residual data manually after cancellation.

Additional constraints:

  • Unscheduled and already-completed tasks (succeeded or failed) are removed from the queue.

  • To cancel a task by alias, first query its job ID using SHOW JOB STATUS WHERE job_name='alias', then cancel by ID.

Syntax

CANCEL JOB 'job_id';

Example

CANCEL JOB '2017112122202917203100908203303000715';