Updated on 2022-07-29 GMT+08:00

Managing the History of Executed SQL Queries

Data Studio allows viewing and managing frequently executed SQL queries. The history of executed SQL queries is saved only in SQL Terminal.

Perform the following steps to view the history of executed SQL queries:

  1. Click in SQL Terminal.

    The SQL History dialog box is displayed.

The scripts of historical SQL queries are not encrypted.

The number of queries displayed in the SQL History dialog box depends on the value set in Preferences > Editor > SQL History. For details about setting the value, see SQL History. Data Studio overwrites the older queries into the SQL history after the list is full. The executed queries are automatically stored in the list.

The SQL History dialog box contains the following columns:

  • Pin Status: displays whether a query remains on the top. Pinned queries remain on the top and will not be deleted from the history even when the list is full.
  • SQL Statement: displays the SQL query. The maximum number of characters for a SQL query displayed in the SQL Statement column depends on the value set in Preferences > Editor > SQL History. For details about modifying the value, see SQL History.
  • Number of Records: displays the number of records obtained by the SQL query
  • Start Time: displays the time when the query was executed
  • Execution Time: displays the duration of the query execution
  • Database Name: displays the name of the database
  • Execution Status: displays the status of the executed query, which can be Success or Failure

The connection information is deleted together with the query history. If the SQL History dialog box is closed, the query is not removed from the list.

You can perform the following operations in the SQL History dialog box:

Loading a SQL Query into the SQL Terminal Pane

Perform the following steps to load a SQL query into the SQL Terminal pane:

  1. Select the required query and click .

    The query is added to the cursor position in SQL Terminal.

Loading Multiple SQL Queries into the SQL Terminal Pane

You can click the Load in SQL Terminal and close History button to load selected queries into SQL Terminal and close the SQL History dialog box.

Perform the following steps to load multiple selected SQL queries into the SQL Terminal pane:

  1. Select the required queries.
  2. Click .

    The queries are added to the cursor position in SQL Terminal.

If you continue the execution upon an error, each statement in SQL Terminal will be executed in sequence as a scheduled job. The execution status is updated in the console and each job is listed in the progress bar. When the time difference between Job Execution, Progress Bar Update and Console Update is small, you will not be able to stop the execution by opening the progress bar. In this case, you need to close SQL Terminal to stop the execution.

Loading More Records

To load more data in the Result tab, you need to scroll down to bottom, which is inconvenient in some scenarios. Data Studio provides a button that simplifies the loading operation.

Perform the following steps to load more records:

  1. Select the required queries and click .

    All the required records are listed.

Deleting a SQL Query

Perform the following steps to delete a SQL query from the SQL History list:

  1. Select the required query and click .

    A confirmation dialog box is displayed.

  2. Click OK.

Deleting All SQL Queries

Perform the following steps to delete all SQL queries from the SQL History list:

  1. Click .

    A confirmation dialog box is displayed.

  2. Click OK.

Pinning a SQL Query

You can pin queries that you do not want Data Studio to delete automatically from SQL History. You can pin a maximum of 50 queries. Pinned queries are displayed at the top of the list. The value set in SQL History does not affect the pinned queries. For details, see SQL History.

The pinned queries are displayed at the top of the list once the SQL History pane is closed and opened again.

Perform the following steps to pin a SQL query:

  1. Select the required SQL query and click .

    The Pin Status column displays the pinned status of the query.

Unpinning a SQL Query

Perform the following steps to unpin a SQL query:

  1. Select the required SQL query and click .

    The Pin Status column displays the unpinned status of the query.