This topic describes the definition of a query template and the operations that you can perform on a custom query template.
Definition of a query template
A query template is a tool that you can use for advanced search. Query templates are classified into sample query templates that are provided by Resource Management and custom query templates. You can use a query template to quickly identify the resources that you require.
Sample query templates: Sample query templates can meet your query requirements in some common scenarios. You can directly use a sample query template to quickly query resources. You can also modify the query statement in a sample query template to query resources. For more information about the sample query templates that are provided by Resource Management, see Supported sample query templates.
Custom query templates: You can create a custom query template and define a query statement and properties in the template based on your business requirements.
You can modify, duplicate, or delete a custom query template. You are not allowed to edit the name or description of a sample query template, or duplicate or delete a sample query template. To save modifications to the query statement in a sample query template, you can only save it as a custom query template.
Create a custom query template
Log on to the Resource Management console.
In the left-side navigation pane, choose
.In the code editor displayed on the Temporary _Query_1 tab, write the query statement. Alternatively, click the + icon to expand a new tab and write the query statement in the code editor displayed on the tab.
The query statement that you write must comply with the basic SQL syntax. For more information about the basic SQL syntax, see Basic SQL syntax.
The system provides the following features to help you quickly write the query statement:
Automatic fill: The Resource Property pane displays the Alibaba Cloud services, resource types, and resource properties that are supported by the advanced search feature. You can click the required resource types and resource properties to add them to code in the code editor.
Code hinting and automatic completion: Resource Management also provides the code hinting feature and automatic completion feature for advanced search. When you write code in the code editor, the system provides code hints such as keywords and properties based on the content that you enter. This can help you quickly complete the writing of the query statement.
Click Run to run the code and check whether the query result meets your expectations.
Click Save to save the query statement as a custom query template.
You can modify the query statement in a sample query template or an existing custom query template and click Save As to save the modified template as a new custom query template.
Modify a custom query template
In the Custom Query Template section on the Quick Start tab of the Advanced page, find the custom query template that you want to modify and click the
icon to the right of the template name.
Click Edit Query Template.
In the Edit Query Template dialog box, modify the name and description of the custom query template and click OK.
NoteYou cannot modify the query statement in a custom query template in the Edit Query Template dialog box. If you want to modify the query statement, you can click Open in the card that displays basic information of the custom query template, modify the query statement in the code editor in the upper part of the Advanced page, and then click Save.
Duplicate a custom query template
In the Custom Query Template section on the Quick Start tab of the Advanced page, find the custom query template that you want to duplicate and click the
icon to the right of the template name.
Click Duplicate Query Template.
In the Duplicate Query Template dialog box, enter a name in the Query Template Name field and a description in the Query Template Description field and click OK.
NoteWhen you duplicate a custom query template, you cannot modify the query statement in the template.
Delete a custom query template
In the Custom Query Template section on the Quick Start tab of the Advanced page, find the custom query template that you want to delete and click the
icon to the right of the template name.
Click Delete Query Template.
In the Delete Query Template message, click OK.