SQL Console

Updated at:

The SQL Console in Data Management (DMS) lets you execute various SQL statements and provides a visual interface to manage data in your database, making it ideal for tasks like data querying and development.

Prerequisites

You must have query permissions on the target database or table. To apply for permissions, see Apply for asset permissions by submitting a ticket.

SQL Console interface

Table 1. SQL Console interface components

Area

Section

Description

Left-side resource tree

Visual operation section

Manage your database visually.

  • Table

    You can view all tables in the current database, including their columns, column types, and indexes. You can also right-click a table to edit its structure, manage it, export or import data, and perform batch operations.

  • Programmable Object

    Create, view, execute, and manage Programmable Objects, such as views, stored procedures, functions, triggers, and events.

    Note

    The console displays up to 1,000 entries.

  • key-value pair information

    Note

    DMS displays this information for NoSQL databases.

  • Backup data

    ApsaraDB RDS for MySQL instances support historical backup data queries. You can query data from a full backup at a specific point in time in the DMS console.

Top toolbar

Extended features section

The following features are available:

  • tubiao (Apply for data owner/Change control): Click this icon to apply to be a data owner or to configure DDL, DML, and SELECT change permissions for the target database.

  • Table Details (Table List): Click this icon to switch to the Table List page, and click the Query icon to return to the Query page.

  • image..png (Enhanced E-R): Click this icon to visualize the relationships between assets in a database you own. For more information, see Enhanced E-R.

  • 数据分析图标 (Data Analysis): Click this icon to create a data analysis ticket. For more information, see One-click data warehousing.

    Note

    This icon is displayed only for ApsaraDB RDS for MySQL databases.

  • shujuku (Database Analysis): Provides database autonomy services such as one-click diagnostics, real-time performance, instance sessions, and space analysis through Database Autonomy Service (DAS). You are redirected to the DAS console. For more information, see Real-time Performance and Instance Session.

  • anquanfangwen (secure access proxy): Provides more comprehensive security for your database. For more information, see Enable the secure access proxy.

  • 同步元数据 (Sync Metadata): After you click this button, DMS collects the latest metadata from the database, such as tables, columns, indexes, and Programmable Objects. This enables hierarchical permission control for tables, columns, and Programmable Objects. For more information, see metadata.

  • 导出 (Export): Use the export feature to export a database, its table structure, or table creation statements. You can also access the Manage Table Structure Versions page.

  • 5控制台-操作审计 (operation audit): The operation audit feature saves all data query and change records. You can query details like the operation, the user, and the time of the operation. For more information, see operation audit.

    The risk audit feature collects and assesses various risks associated with database usage. For more information, see Risk audit report.

  • 分享功能图标 (Share): Use this feature to share the console and commands for this database with relevant personnel. For more information, see Share an SQL Console.

  • 超级SQL (Super SQL Mode): After you enable Super SQL Mode, administrators and DBAs can execute SQL statements in the SQL Console without being restricted by security rules. For more information, see Super SQL Mode.

SQL editor pane

Command execution section

Enter an SQL statement and click Execute to perform operations on the database. Other features are also available, such as Format, execution plan, and Settings.

  • Execute: Click Execute to run the SQL statement you entered.

  • Format: Click Format to optimize the format of your SQL statement.

    For example, if you enter SELECT * FROM `test_table`; and click Format, the SQL statement is formatted as follows:

    SELECT
      *
    FROM
      `test_table`;
  • Execution plan: View the execution plan for the SQL statement you entered.

Note

You can click the 增加页签 icon in the upper-right corner of the page to open multiple SQL Console windows.

Bottom log pane

Execution results section

After you execute an SQL statement, you can view the results. You can also view row details, add rows, delete rows, and submit changes.

Note

Click Execution History to view the SQL execution history, which includes details such as the start time, database, and SQL, and can be exported.

Default behavior and limits

  • If a table contains sensitive or confidential columns and you do not have the required permissions, the query results show ****** for these columns. For more information, see Sensitive data management.

  • Note the following about the number of rows returned by a database query:

    • For a database in Flexible Management mode or Stable Change mode, the default maximum number of rows returned is 3,000.

    • For a database in Security Collaboration mode, the default number of rows returned is 200, and the system-defined maximum is 3,000. An administrator can modify the number of rows returned in the Basic Configuration Item section by navigating to Security and Specifications > Security Rules > SQL Console.

      Note

      If you need to query more data without being restricted by security rules, you can export the data to your local computer for analysis. If a table contains sensitive columns, you can apply for permissions to export their data before you export the data. For more information about how to apply for permissions and export data, see Apply for permissions by using a ticket and Export database data.

  • The maximum size for a full table scan is 10 GB. An administrator can modify this value by navigating to Security and Specifications > Security Rules.

  • The default timeout for executing a single SQL statement is 60 seconds. An administrator can modify this value by navigating to Instances > More > Edit > Advanced Information.

Procedure

  1. Log in to DMS 5.0.

  2. In the top navigation bar, choose SQL Console > SQL Console.

    Note

    If you are using the console in Simple mode, click the 2023-01-28_15-57-17 icon in the upper-left corner and choose All functions > SQL Console > SQL Console.

  3. In the Select Database dialog box, search for and select a database, and then click Confirm.

  4. In the SQL Console area, enter an SQL statement, and then click Execute.

FAQ

Q: I use Data Management Service (DMS) to log in to a MongoDB instance. When I execute an SQL statement, I receive the error 'Incomplete command. Please check.'

A: Some MongoDB commands require the new parser. Click Open Parser to switch to the new parser. For a complete list of commands supported by the new parser, see Supported MongoDB commands.

Q: After I log on to DMS and access the SQL Console, I receive the error "Authorization failed for the GetSqlConsoleExecutionHistory action on the acs:dms:*:*:sqlConsole/* resource. No permission policy matched."

A: This error indicates that your account does not have the GetSqlConsoleExecutionHistory permission. We recommend the following solutions:

  • Use the Alibaba Cloud account (or an administrator account with management permissions) to grant the AliyunDMSFullAccess (DMS full management) permission to the current account. If you only need to query data in SQL Console, you can also grant the AliyunDMSReadOnlyAccess (DMS read-only) permission. Both permission policies include the GetSqlConsoleExecutionHistory permission. For more information about how to grant permissions, see Grant permissions to a RAM user.

  • Create a custom permission policy that includes the GetSqlConsoleExecutionHistory permission and attach it to your account. The following example shows the required permission policy:

    {
    "Effect": "Allow",
    "Action": "dms:GetSqlConsoleExecutionHistory",
    "Resource": "acs:dms:::sqlConsole/*"
    }

    For more information about how to create a custom policy, see Create a custom policy.

Q: The SQL Console freezes, shows "Waiting for user action", or the connection is unstable when I execute an SQL statement. What should I do?

A: Refer to the following solutions based on your specific symptom:

  • Frozen interface: Exit Simple mode and switch to Standard mode, or access DMS using your browser's incognito (private browsing) mode.

  • "Waiting for user action" message: This typically means the SQL statement has not actually been sent to the database (no corresponding session exists in the real-time session list). Cancel the current task, re-execute the SQL statement, and verify that execution has started.

  • Intermittent connection instability: Some features in the new DMS console have been taken offline due to known issues. We recommend switching back to the previous version of the DMS console and monitoring whether the connection becomes stable.

Q: How do I clear or edit the My SQL or Frequently Used SQL history?

A: The My SQL and Frequently Used SQL features in DMS SQL Console are still being improved. Clearing, deleting, or editing saved SQL history is not yet supported. If you need to clear the history, wait for a future version update or contact backend support for assistance.

Q: Selecting all SQL statements and executing them at once causes slow execution or a hang. What should I do?

A: Executing multiple SQL statements at once in the DMS SQL Console — for example, running CREATE TABLE and INSERT statements together — may cause slow processing or a hang. We recommend executing CREATE TABLE statements and INSERT statements separately.

Q: I cannot terminate a database process that was not created by me. What should I do?

A: For security reasons, DMS restricts users to terminating only the session threads they created themselves. You can use one of the following methods to terminate the process:

  1. Ask the administrator or DBA who owns the account associated with the thread to log on to DMS or connect to the database directly to run the KILL command.

  2. If you have management permissions for the ApsaraDB RDS instance, go to the ApsaraDB RDS console, navigate to Autonomy Service > Session Management for the target instance, search for the thread ID, and click End Session. This approach bypasses the DMS permission restrictions.

Related documents

After you understand the features of the SQL Console interface, you can create tables, query data, or modify data in the SQL Console. For more information, see Get started with the SQL Console.