All Products
Search
Document Center

Hologres:Manage an SQL query task

Last Updated:Feb 27, 2024

This topic describes how to create, edit, delete, copy, and rename an SQL query task in the HoloWeb console. You can create SQL query tasks for interactive short queries. However, SQL query tasks do not apply to scenarios in which a large amount of data is processed offline, such as data import and data export. SQL query tasks also do not apply to SQL queries that last for more than 60 minutes.

Prerequisites

You have logged on to a Hologres instance. For more information, see Log on to an instance.

Create an SQL query task

  1. Log on to the Hologres console.

  2. In the top navigation bar, select a region from the drop-down list.

  3. In the left-side navigation pane of the Hologres console, click Go to HoloWeb to go to the HoloWeb console.

  4. In the HoloWeb console, click SQL Editor in the top navigation bar.

  5. Right-click My SQL query in the left-side navigation pane and select New SQL Query.

  6. In the New SQL Query dialog box, configure the parameters. The system automatically specifies the instance name and database name. New SQL QueryThe following table describes the parameters.

    Parameter

    Description

    Job Name

    The name of the SQL query task.

    Directory

    The directory in which you want to create the SQL query task. The default directory is /My SQL query. You can also specify a folder that you created.

    New Folder

    The custom folder in which you want to create the SQL query task. You can enter a custom folder name to create a folder for the SQL query task.

    Instance Name

    The name of the Hologres instance in which you want to run the SQL query task. You can select an existing instance from the drop-down list.

    Note

    Both connected and disconnected instances are displayed in the drop-down list. To view an SQL query task created for a disconnected instance, you must connect to the instance after you execute SQL statements and save the query results.

    Database Name

    The name of the database in which you want to run the SQL query task in the Hologres instance.

  7. The new SQL query task is displayed in the My SQL query directory in the left-side navigation pane. You can click the name of a table in the Table Directory section to view the names and data types of the fields in the table. You can also use standard PostgreSQL statements to develop data in the SQL editor.

    Note

    The table names and field names in SQL statements are not case-sensitive. If you want to search for a table with an exactly matched name, you need to enclose the name of the table in double quotation marks (") in SQL statements.

    SQL Editor

  8. Optional. Configure a time zone.

    • Configure a time zone for the current SQL query task

      1. In the upper-right corner of the Ad-hoc Query tab, click Document Settings.Document Settings

      2. In the Document Settings dialog box, click Time Zone Setting in the left-side navigation pane.

      3. Select the required time zone from the Configure Time Zone drop-down list and click OK.

        The specified time zone will be used when the system runs the SQL query task.

        Configure Time Zone

    • Configure a global time zone for HoloWeb

      1. In the HoloWeb console, click the username in the upper-right corner.

      2. Select Settings. The User Settings dialog box appears.Set a global time zone for HoloWeb

      3. In the User Settings dialog box, click Time Zone Setting in the left-side navigation pane.

      4. Select the required time zone from the Configure Time Zone drop-down list and click Save.

    Note

    If you configure a global time zone for HoloWeb and a time zone for the current SQL query task at the same time, the time zone configured for the current SQL query task prevails.

  9. Click Run to execute the SQL statements that you enter.

    Note

    In HoloWeb, SQL statements in a query task can be executed for up to 60 minutes. If the SQL statements are executed for more than 60 minutes, the "cancel query due to timeout, queryTimeout setting is: 3600s" error message appears.

  10. Click Save to save the SQL statements in the SQL editor.

View a table

After you create and edit an SQL query task, you can view a table in the Table Directory section to have a better understanding of its schema.

  1. In the HoloWeb console, click SQL Editor in the top navigation bar.

  2. In the left-side navigation pane, click My SQL query. Then, double-click the SQL query task that you want to manage.

    SQL Editor

  3. You can view all internal tables in the Table Directory section. Click a table to view the names and data types of the fields in the table.

    You can also use standard PostgreSQL statements to develop data in the SQL editor. For example, after you execute the CREATE TABLE statement in the SQL editor and click the Refresh icon, you can view the new table in the Table Directory section.

    Note

    The table names and field names in SQL statements are not case-sensitive. If you want to search for a table with an exactly matched name, you need to enclose the name of the table in double quotation marks (") in SQL statements.

Edit an SQL query task

  1. In the left-side navigation pane, click My SQL query. Then, find the SQL query task that you want to manage

    If the SQL query task is in a folder, enter the name of the SQL query task in the search box below Query.Query

  2. Double-click the SQL query task. Then, edit the SQL query task.

  3. You can enter the SQL statements that you want to execute in the SQL editor and click Run.

    In this example, the following SQL statement is executed to create a table:

    CREATE TABLE test (
     "id" bigint NOT NULL,
     "name" text NOT NULL,
     "age" bigint,
     "class" text NOT NULL,
    PRIMARY KEY (id)
    );

    You can view the execution result of the sample statement by checking the table schema in the Table Directory section.

  4. Click Save. After you click Save, the entered SQL statement is saved for the SQL query task.

Delete an SQL query task

  1. In the left-side navigation pane, click My SQL query. Then, find the SQL query task that you want to manage

    If the SQL query task is in a folder, enter the name of the SQL query task in the search box below Query.Query

  2. Right-click the SQL query task and select Delete SQL Query.

  3. Click OK.

Copy an SQL query task

  1. In the left-side navigation pane, click My SQL query. Then, find the SQL query task that you want to manage

    If the SQL query task is in a folder, enter the name of the SQL query task in the search box below Query.Query

  2. Right-click the SQL query task and select Copy SQL Query.

    After you perform this operation, the SQL statements in the selected SQL query task are copied to the clipboard.

  3. Then, paste the copied statements to the SQL editor of the destination SQL query task.

Rename an SQL query task

  1. In the left-side navigation pane, click My SQL query. Then, find the SQL query task that you want to manage

    If the SQL query task is in a folder, enter the name of the SQL query task in the search box below Query.Query

  2. Right-click the SQL query task and select Rename.

  3. In the Rename SQL file dialog box, enter an updated name in the Rename name field.

  4. Click OK.