All Products
Search
Document Center

Data Management:Export SQL result sets

Last Updated:Mar 28, 2026

When you need to export query results from a database managed in DMS, SQL Result Set Export lets you run a SELECT statement and download the output as a file. Exports go through a ticket-based approval workflow so that data leaves the system only after authorization.

Prerequisites

Before you begin, ensure that you have:

  • A database instance of a supported type (see the table below) registered with DMS

  • Export permissions for the target database — see View owned permissions

  • (Required for cross-database exports) A privileged account on the instance to avoid permission errors when exporting from a database other than the one you logged in to

Supported database types

CategoryDatabases
Relational databasesMySQL (ApsaraDB RDS for MySQL, PolarDB for MySQL, ApsaraDB MyBase for MySQL, PolarDB for Xscale, and MySQL databases from other sources); SQL Server (ApsaraDB RDS for SQL Server, ApsaraDB MyBase for SQL Server, and SQL Server databases from other sources); PostgreSQL (ApsaraDB RDS for PostgreSQL, PolarDB for PostgreSQL, ApsaraDB MyBase for PostgreSQL, and PostgreSQL databases from other sources); MariaDB (ApsaraDB RDS for MariaDB and MariaDB databases from other sources); OceanBase (ApsaraDB for OceanBase in MySQL mode, ApsaraDB for OceanBase in Oracle mode, and self-managed OceanBase); PolarDB for PostgreSQL (Compatible with Oracle); Oracle; Dameng (DM); Db2
NoSQL databasesApsaraDB for MongoDB, ApsaraDB for Lindorm, ApsaraDB for Cassandra
Data warehousesAnalyticDB for MySQL, AnalyticDB for PostgreSQL, Data Lake Analytics (DLA), ApsaraDB for ClickHouse, MaxCompute, Hologres

Usage notes

  • Export limits — including the maximum number of rows and the maximum capacity of tables that can be exported at a time — depend on the control mode of your database instance.

  • After a ticket is approved, you have 24 hours to run the export. If you miss this window, create a new ticket. In Security Collaboration mode, you can change this window: go to the security rule set Details page, click Data Export in the left sidebar, and edit the Period for Performing Export after Export Request of SQL Result Set Is Approved configuration item.

  • After the export completes, the file is available for download at any time by default. In Security Collaboration mode, you can restrict the download window using the Period for Downloading Exported File after Export Request of SQL Result Set Is Approved configuration item in the same security rule set. For example, if you set the value to 1, you can only download the file within 1 hour after the ticket is approved.

Export an SQL result set

There are two ways to start an SQL Result Set Export:

  • From the navigation bar: In the top navigation bar of the DMS console V5.0, choose Database Development > Data Export > SQL Result Set Export.

  • From the SQLConsole tab (relational databases and data warehouses only): Run your SQL statement on the SQLConsole tab, then choose Export File > Export more data on the execution result tab.

Step 1: Submit the ticket

On the Ticket Application page, configure the following parameters.

The parameters below reflect an ApsaraDB RDS for MySQL instance managed in Security Collaboration mode. Parameters may differ slightly for other database types.

Basic information

ParameterRequiredDescription
Database NameYesThe database to export from.
Reason CategoryYesThe reason for this export. Used to find the ticket later.
Business BackgroundYesThe purpose or objective of this export.
Affected RowsYesEstimated number of rows to export. To get the exact count, run the COUNT function on the SQLConsole tab. DMS shows the actual row count in the Precheck step so you can verify it before the export runs.
Skip ValidationNoIf selected, DMS skips the row-count check. Enter a reason if you enable this.
StakeholderNoAdditional users who can view the ticket and participate in approval. Users not listed here (other than DMS administrators and database administrators (DBAs)) cannot access the ticket.
AttachmentsNoSupporting images or files.
Warning

If you enable Skip Validation, DMS does not check the number of rows to be exported. Exporting a large amount of data may affect your business. Proceed with caution.

Export statement

ParameterRequiredDescription
Export StatementYesThe SELECT statement to run. Example: SELECT * FROM testtable. Only SELECT statements are supported. DMS validates the syntax when you submit.

Watermark settings

ParameterRequiredDescription
Embed WatermarkYesWhether to embed a watermark. Valid values: Yes, No. If you select Yes, set the export Format to EXCEL.
Embedding MethodYesHow to embed the watermark. Data Watermark: embeds identification information into the data itself — invisible to the reader. File Watermark: embeds identification information into the file — visible to the reader.
File Watermark MessageYesThe watermark text to embed in the file.
Data Watermark MessageYesThe watermark text to embed in the data.
Embedded FieldNoThe field to embed the watermark in. If left blank, DMS selects one automatically.
Primary key / Unique KeyNoOne or more primary keys or unique keys, separated by commas. Specifying a key improves watermark robustness.

Click Submit. DMS runs a precheck on your SQL statement. Wait for the precheck to complete.

Step 2: Get approval

Click Submit for Approval. Track progress in the Approval step on the Ticket Details page.

Important

You must run the export within 24 hours of approval. See Usage notes for how to change this window in Security Collaboration mode.

Step 3: Configure and run the export

In the Execute/Automatic Execution step, click Export. In the Export Settings dialog, configure the following parameters.

Format and encoding

ParameterRequiredOptionsNotes
FormatYesCSV, EXCEL, SQL, JSONJSON is available for NoSQL databases only. If Embed Watermark is set to Yes, select EXCEL. If Watermark for Exported SQL Result Sets is enabled, this parameter is unavailable — go to O&M > Configuration Management to disable it, then retry.
Character SetYesDefault Character Set, GBK, UTF-8, ISO-8859-1
Add Field CommentNoOn / OffAvailable only for MySQL databases with CSV format. Adds field comments in the row next to the field names in the export results.

Execution

ParameterRequiredOptionsNotes
Execution StrategyYesRunning immediately: starts as soon as you confirm. Schedule: runs at a time you specify (useful for off-peak hours).Scheduling cannot be changed after confirmation.
Export ModeYesSpeed Mode: faster, but cannot be stopped mid-run. Ordinary Mode: can be stopped during the export.
Export TimeNo0–2,147,483 secondsTimeout for the export task. If not set, the instance-level timeout applies. If the task exceeds this limit before finishing, it fails.

Click Confirm. DMS starts the export based on your configuration. Monitor progress in the Execute/Automatic Execution step.

Step 4: Download the file

After the export completes, click Download Exported File to save the file to your local machine.

Important

In Security Collaboration mode, the download window may be restricted. See Usage notes for details.

What's next