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
Log on to the Hologres console.
In the top navigation bar, select a region from the drop-down list.
In the left-side navigation pane of the Hologres console, click Go to HoloWeb to go to the HoloWeb console.
In the HoloWeb console, click in the top navigation bar.
Right-click My SQL query in the left-side navigation pane and select Create SQL Query.
In the Create SQL Query dialog box, configure the parameters. The system automatically specifies the instance name and database name. The 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.
NoteBoth 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.
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.
NoteThe 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.
Optional. Configure a time zone.
Configure a time zone for the current SQL query task
On the configuration page of the SQL query task, click Document Settings.
In the Document Settings dialog box, click Time Zone Setting in the left-side navigation pane.
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 a global time zone for HoloWeb
In the upper-right corner of the HoloWeb console, click Settings. The User Settings dialog box appears.
In the User Settings dialog box, click Time Zone Setting in the left-side navigation pane.
Select the required time zone from the Configure Time Zone drop-down list and click Save.
NoteIf 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.
Click Run to execute the SQL statements that you enter.
NoteIn 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.If you set the statement_timeout parameter to be greater than 60 minutes, this parameter does not take effect for SQL statements in HoloWeb. For more information about how to configure the statement_timeout parameter, see the "Change the timeout period of active queries" section in Manage queries.
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.
In the HoloWeb console, click in the top navigation bar.
In the left-side navigation pane, click My SQL query. Then, double-click the SQL query task that you want to manage.
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 icon, you can view the new table in the Table Directory section.
NoteThe 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
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.
Double-click the SQL query task. Then, edit the SQL query task.
You can enter the SQL statements that you want to execute in the SQL editor and click Running.
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.
Click Save. After you click Save, the entered SQL statement is saved for the SQL query task.
Delete an SQL query task
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.
Right-click the SQL query task and select Delete SQL Query Task.
In the message that appears, click OK.
Copy an SQL query task
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.
Right-click the SQL query task and select Copy SQL Query Task.
After you perform this operation, the SQL statements in the selected SQL query task are copied to the clipboard.
Then, paste the copied statements to the SQL editor of the destination SQL query task.
Rename an SQL query task
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.
Right-click the SQL query task and select Rename.
In the Rename SQL file dialog box, enter an updated name in the New Name field.
Click OK.