When you need to import data from a local file or a file stored in Cloud Object Storage (COS) into a specified database table, you can submit a data import request ticket. Similarly, when you need to export data from a specified database table, you can submit a data export request ticket.
The ticket import/export process supports multiple file formats (supported formats: SQL, CSV and Excel) and performs syntax analysis, semantic analysis, and data verification before execution to ensure data quality and reduce manual errors. Additionally, the approval workflow ensures database security.
Supported Databases
Only MySQL databases are supported. For the specific supported versions, please refer to Supported Databases. Implementation Logic
1. Create a data import ticket, select the target instance, database, execution mode, file type (supported formats: SQL, CSV and Excel), file encoding, import file, and other configuration details.
2. After you submit the ticket, the system will automatically perform SQL syntax analysis. After the check passes, the process moves to the semantic analysis stage. After the check passes, the request proceeds to approval. If the check fails, the SQL statements should be modified. Syntax and semantic analyses apply only to SQL file imports.
3. Once parsing is successful, the ticket enters the approval workflow. After approval, it is automatically added to the execution queue.
4. After entering the execution queue, the ticket can be executed in one of the following modes: automatic execution, manual execution, or scheduled execution.
5. In the execution phase, the system performs ticket configuration parsing and SQL import.
5.1 Parse the ticket configuration.
5.2 For SQL files, the system streams splits, and aggregates SQL statements. For CSV and Excel files, data is stream-processed into aggregated SQL blocks, optimizing write performance while minimizing database load.
5.3 Stream SQL statements into the target instance.
6. Display execution results and execution details.
1. Create a data export ticket and select the target execution instance, database, execution mode, file type (supported formats: SQL, CSV and Excel), export format, export scheme, and other configuration details.
2. After you submit the ticket, the system will automatically perform SQL syntax analysis. After the check passes, the process moves to the semantic analysis stage. After the check passes, the request proceeds to approval. If the check fails, the SQL statements should be modified. Syntax and semantic analyses apply only to SQL file imports.
3. Once parsing is successful, the ticket enters the approval workflow. After approval, it is automatically added to the execution queue.
4. After entering the execution queue, the ticket can be executed in one of the following modes: automatic execution, manual execution, or scheduled execution.
5. In the execution phase, the system performs ticket configuration parsing and data export.
5.1 Parse the ticket configuration.
5.2 For SQL files, the dump service retrieves exported data from the source instance. For CSV and Excel files, the database client service retrieves exported data from the source instance.
5.3 Stream the exported data to the internal COS service for storage.
6. Display execution results and provide the download link for the exported file.
Data import and export tasks are executed in single-threaded mode.
Impact Description
Import Impact Description
Description and influences of write locks in import tasks.
When importing CSV or Excel files, the system automatically applies a write lock on the target table. During the import process, no other threads can perform read or write operations on the table. Write lock SQL statements:
Before import: LOCK TABLES table_test WRITE
After import (whether succeeded or failed): UNLOCK TABLES
Write locks apply to both InnoDB and MyISAM storage engines.
If the imported SQL file contains syntax errors, the ticket will fail during syntax analysis after submission.
If the SQL file does not comply with the SQL change rule template bound to the target instance, the ticket will fail during semantic analysis.
If the database instance experiences high load during the import process, the task may fail or become unresponsive.
Export Impact Description
Description and impact of read locks in export tasks.
When exporting data in SQL format using the table export scheme, it is recommended to enable table locking to ensure data consistency.
If you export SQL files using custom SQL queries, the system automatically applies a read lock on the target table. Whether a read lock is applied depends on the specific table structure and SQL query.
If you export data in CSV or Excel format, the system does not explicitly apply a read lock by default. Whether a read lock is applied depends on the table structure and SQL query.
During export, other threads cannot perform write operations on the locked table.
Read lock SQL statements:
Before export: LOCK TABLES table_test READ
After export (success or failure): UNLOCK TABLES
Read locks apply to both InnoDB and MyISAM storage engines.
Exporting large datasets may lead to increased I/O usage on the instance. To optimize performance, consider scaling up the instance or reducing other database operations during the export process.
Use Limits
Only MySQL databases support data import and export.
For SQL and CSV files, the maximum size is 3 GB. For Excel files, the maximum size is 10 MB. Only the .xlsx format is supported; other formats may have compatibility issues.
A primary account or sub-account can run up to 7 concurrent import/export tasks in Executing or To be execution status. Large tasks (files over 500 MB) are limited to 2 concurrent import/export tasks in Executing or To be execution status.
Prerequisites
The sub-account has the necessary access permissions for DMC-related feature pages. For details and operations, see DMC User Permission Settings. The root account has full permissions by default. Directions
2. In the left sidebar, select Secure Release > Creation Process > Import/Export.
3. Create an import/export ticket.
Click Import at the top of the page to configure parameters.
|
Instance | Select the instance to be executed. The list will display the corresponding data source name and ID for each instance. |
Target Database | Supports selecting the database to be executed. |
Execution Method | Select the execution mode, including: Manually Execution: After the ticket is approved, SQL statements should be manually triggered for execution. Automatic Execution: After the ticket is approved, it automatically enters the execution queue, executing the SQL changes. Scheduled Execution: Select the execution time. After approval, the ticket enters the execution queue at the scheduled time to execute the SQL changes. |
File Type | Supported file types: SQL, CSV, and Excel. SQL: After selecting the SQL file type, choose the import file accordingly. More: Click to Display, and select whether to ignore foreign keys. CSV and Excel: After selecting CSV or Excel, configure the following additional parameters: Import Table: Select the table to which the data will be imported. Lock Table: Select whether to lock the table. Column Name: Specify whether the import file contains column names. Import Method: Choose between Insert or Replace. Separator: Any string can be used as a delimiter except double quotes (") and the Tab key. The default is a comma (,). Applicable to CSV files only. The delimiter takes effect when reading the data, splitting each row into different fields. For example, if a row contains "ad","po","vb", and the delimiter is a comma, the row will be split into three fields, each corresponding to a column name. These values are used as insert values when generating SQL statements. |
File Encoding | Select the file encoding format from the following options: UTF-8, GBK, GB2312, or Latin1. |
Import File | Click Click to Upload to upload a local file, or drag and drop the file to the designated area. Only .sql and .csv files within 3 GB and .xlsx files within 10 MB are allowed. |
Reason | Provide the reason for data import or export to facilitate faster approval. |
Click Export at the top of the page to configure parameters.
|
Instance | Select the instance to be executed. The list will display the corresponding data source name and ID for each instance. |
Export Solution | Select the export method: Export Table: Export by table. Export SQL Statement: Export the query results based on a custom SQL statement. Note: When Export SQL Statement is selected, JOIN, subquery, and other complex SQL statements are not supported for export. Reference syntax: select * from ruirui_test where id > 5 order by id desc limit 30; |
Target Database | Select the database to be exported. |
Target Table | Select the export scope (only displayed under the Export Table solution): All Tables: Export all tables in the selected database. Partial Tables: Customize the tables to be exported. |
File Type | Select the export file format: SQL, CSV, or Excel. The file size must not exceed 3 GB. |
Column Name | Only displayed when the file type is CSV or Excel. When enabled, the exported file will include column names (enabled by default). |
File Encoding | Select the file encoding format, including utf8, utf8mb4, gbk, gb2312, and latin1. |
Exported Content | Only displayed when SQL file type and Export Table solution are selected: Data: Export table data only. Structure: Export table structure only. Data and structure: Export both table structure and data. |
Export Execute SQL | Only displayed under the Export SQL Statement solution. Enter the SQL statement to be executed for exporting the results. |
Advanced Option | Click to expand and configure the following advanced parameters (only displayed when Export Table solution and SQL file type are selected). |
Lock Table | Specify whether to lock the table during export. Disabled by default (table is not locked). Caution: Locking the table ensures data consistency during the export process, but you need to be aware that read locks will be applied to the tables to be exported. Write operations will be blocked until the locks are released. |
Export Object | Select the database objects to be exported, including Event, Trigger, View, and Stored procedures and functions. |
Data Option | When selected, dump binary fields using hexadecimal notation during export. |
Others | Configure additional export options: Compress Multiple Insert Statements for Batch Write: Merge multiple INSERT statements to improve write efficiency. Generate a DROP statement before CREATE statement: Add a corresponding DROP statement before each CREATE statement. Generate a TRUNCATE TABLE statement before INSERT statement: Add a TRUNCATE TABLE statement before each INSERT statement. Note: When Generate a DROP statement before CREATE statement is enabled, the differences between regular tables and views are as follows: Regular table: A DROP TABLE statement is added before the CREATE statement (if the table exists). Example: DROP TABLE IF EXISTS xxx; View: A statement to delete the view is added before the CREATE VIEW statement. Example: DROP VIEW IF EXISTS xxx; When Generate a TRUNCATE TABLE statement before INSERT statement is enabled, all existing data in the target table will be cleared before the INSERT operation is performed to insert the new data. The cleared data cannot be restored, so use this option with caution. |
Execution Method | Select the execution mode, including: Manually Execution: After the ticket is approved, SQL statements should be manually triggered for execution. Automatic Execution: After the ticket is approved, it automatically enters the execution queue, executing the SQL changes. Scheduled Execution: Select the execution time. After approval, the ticket enters the execution queue at the scheduled time to execute the SQL changes. |
Reason | Provide the reason for data import or export to facilitate faster approval. |
4. After you complete the configuration, click OK.
Once the ticket is submitted, the system will automatically perform syntax analysis and semantic analysis.
5. View the ticket status and ticket details.
After submission, the system automatically redirects to the ticket details page, displaying the ticket details, ticket status, and parsing result.
You can also select the My Request tab on the Process Management > Ticket List tab to check the ticket status and details. For detailed steps, see Ticket List. Both grammar and semantics checks succeeded
If the parsing results indicate success, the ticket status updates to Reviewing. You can directly proceed to the next step.
Syntax check failed
Click Edit Import Settings to modify the import file, and then click OK. Repeat until the ticket status updates to Reviewing, and then proceed to the next step.
If exporting data, click Edit Export Settings to modify the SQL statement, and then click OK. Repeat until the ticket status updates to Reviewing, and then proceed to the next step.
Syntax check succeeded but semantics check failed
Click Edit Import Settings to modify the import file, and then click OK. Repeat until the ticket status updates to Reviewing, and then proceed to the next step.
If exporting data, click Edit Export Settings to modify the SQL statement, and then click OK. Repeat until the ticket status updates to Reviewing, and then proceed to the next step.
6. Wait for the approval result.
Select Process Management > Ticket List in the left sidebar, choose the My Request tab, and view the ticket status in the ticket list.
In Approval: The ticket is under review. Once approved, the status updates to In Execution Queue, and then you can proceed to the next step.
In Execution Queue: The ticket has been approved and is now queued for execution. You can proceed to the next step.
Rejected: The ticket has been rejected. Click the ticket ID or select View in the Operations column, and then click Approval Information in the upper-right corner of the ticket detail page to check the rejection reasons.
7. Execute the ticket.
Manual Execution: Select manual execution during the ticket request, you can execute the ticket using one of the following methods:
Method 1: In the left sidebar, select Process Management > Ticket List, choose the My To Do or My Request tab, click To Execute in the corresponding Operation column of the ticket, go to the execution details page, and click Execute at the top of the page to execute immediately.
Method 2: In the left sidebar, select Process Management > Execution List, choose the Waiting for queue... tab, click Execute in the corresponding operation column of the ticket, and click OK in the pop-up dialog box to execute immediately.
Automatic Execution: If automatic execution is selected, the ticket will be executed automatically once approved. You can check the status on Ticket List > My Applications page.
Scheduled Execution: If scheduled execution was selected, the ticket will be executed at the specified time after approval. You can check the status on the Ticket List > My Applications page.
8. View the execution result.
Select Process Management > Execution List in the left sidebar and choose the Execution History tab, or select Process Management > Ticket List in the left sidebar, and choose the My Request tab to view the ticket status.
Executing: The execution is ongoing. Wait for the result, which may be Failed or Completed.
Execution Failed: You can click the execution ID on the Execution History page or click View in the Operation column to check SQL details, failure reasons, and historical monitoring data.
Completed: The execution is successful. Click the execution ID on the Execution History page or select View in the Operation column to view execution details and historical monitoring data.
9. (For data export) Download the exported file.
9.1 In the left sidebar, select Process Management > Execution List and choose the Execution History tab. Select the time, and click Download in the Operation column corresponding to the executed ticket.
9.2 In the pop-up dialog box, download the file in .zip format.
Click Copy Download Link, open a browser window, and download the exported data.
Click Download to retrieve the file.