Updated on 2024-08-29 GMT+08:00

Executing SQL Statements

This section describes how to execute various SQL statements.

Procedure

  1. Log in to the DAS console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane on the left, choose Development Tool.

    You can also click Go to Development Tool on the overview page.

  5. Locate the DB instance that you want to log in to and click Log In in the Operation column.
  6. On the top menu bar, choose SQL Operations > SQL Query.

    Figure 1 Opening the SQL window

  7. In the upper left corner of the page, select a database and schema.

    Figure 2 Selecting a database

  8. Enter a SQL statement in the SQL window and click Execute SQL.

    Figure 3 Executing a SQL Statement
    • Enabling SQL Input Prompt is recommended. It helps you select the required database, table, or field name when you enter a SQL statement in the SQL window.
    • To protect query result sets from being displayed as garbled characters, select an encoding format other than the default encoding format, UTF-8.
    • You can execute multiple SQL statements at a time. Separate them using semicolons (;). You can click Full Screen to view logics in SQL statements clearly.
      • To execute some of the SQL statements, select the statements before executing them.
      • To execute all SQL statements, do not select any SQL statements or select all SQL statements.

  9. View execution details of the current SQL statement and previously executed SQL statements in the lower part of the page.

    Figure 4 Viewing execution records

  10. Click the Messages tab, view SQL execution details, including affected rows, progress, and time required.

    Figure 5 Viewing messages

  11. On the Result Set tab, view SQL execution results.

    Figure 6 Viewing result sets

    You can also perform the operations described in Table 1 on result sets.

    Table 1 Operations

    Function

    Description

    Copy Row and Copy Column

    Copies a row or column for reuse.

    Column Settings

    Customizes the display of columns when there are a number of columns in the query result.

    Convert binary to hexadecimal

    Converts binary data in the result set into hexadecimal data for display.

    Refresh

    Refreshes changed data.

    Row Details

    Displays the column field name, type, and data of the selected row.

    Add Row

    Adds an empty row to the result set.

    Submit

    Views the SQL statements to be modified. After you click OK, the result set is updated.

    Delete Row

    Deletes the selected row, including data.

    Export

    Allows you to export data in a SQL or CSV file. A maximum of 10,000 rows of data can be exported.

    Export More

    Redirects you to the data export page and allows you to export over 10,000 rows of data.

    • If the result set involves a view, data in the result set cannot be edited.
    • If the type of the result set is metadata, the data cannot be edited or displayed on multiple pages.
    • If the result set involves multiple tables, data in the result set cannot be edited.
    • If the result set involves only one table and does not include all the primary key columns of the table or no primary key is found, data in the result set cannot be edited.
    • Data in virtual tables (for example, tables generated during execution of a stored procedure) cannot be edited.