Help Center/ Data Admin Service/ API Reference/ APIs/ Intelligent O&M/ Obtaining the SQL Template List
Updated on 2026-08-25 GMT+08:00

Obtaining the SQL Template List

Function

This API is used to obtain the SQL template list.

Authorization Information

Each account has permissions to call all APIs, but IAM users must have the required permissions specifically assigned.

  • If you are using role/policy-based authorization, see the required permissions in Permissions Policies and Supported Actions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    das:clouddba:topSqlList

    Read

    Instance

    -

    -

    -

URI

POST /v3/{project_id}/fullsql/query-sql-tpl-list

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region.

To obtain the value, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are supported.

Default Value

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

instance_id

Yes

String

Definition

Unique ID of an instance

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are supported.

Default Value

N/A

node_id

No

String

Definition

Unique ID of a node

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are supported.

Default Value

N/A

start_at

Yes

Long

Definition

Start time

Constraints

Unix timestamp, in milliseconds

Range

[0, 2^31 – 1]. The actual value depends on the query result.

Default Value

N/A

end_at

Yes

Long

Definition

End time

Constraints

Unix timestamp, in milliseconds

Range

[0, 2^31 – 1]. The actual value depends on the query result.

Default Value

N/A

operation

No

String

Definition

Operation type

Constraints

Multiple values need to be separated by commas (,).

Range

N/A

Default Value

N/A

db_name_list

No

Array of Strings

Definition

Database

Constraints

N/A

Range

N/A

Default Value

N/A

keyword

No

String

Definition

Keyword

Constraints

N/A

Range

N/A

Default Value

N/A

sql_template_id

No

String

Definition

SQL template ID

Constraints

N/A

Range

N/A

Default Value

N/A

sort

No

String

Definition

Sorting field

Constraints

executeNum: execution times; totalCost: total duration; avgCost: average duration; totalScan: scanned rows; avgScan: average scanned rows

Range

N/A

Default Value

N/A

asc

No

Boolean

Definition

Sorting order

Constraints

N/A

Range

  • true: ascending
  • false: descending

Default Value

N/A

size

No

Integer

Definition

Quantity. The default value is 30.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

tpl_list

Array of objects in Table 4

Definition

SQL template list

Range

N/A

Table 4 tpl

Parameter

Type

Description

template_id

String

Definition

SQL template ID

Range

N/A

sql_template

String

Definition

SQL template

Range

N/A

sql_sample_string

String

Definition

SQL example

Range

N/A

db_names

Arrays of Strings

Definition

Database list

Range

N/A

sql_type

String

Definition

SQL type

Range

N/A

execute_num

Long

Definition

Execution times

Range

N/A

total_cost

Double

Definition

Total execution time, in milliseconds

Range

N/A

avg_cost

Double

Definition

Average execution duration, in milliseconds

Range

N/A

max_cost

Double

Definition

Maximum execution duration, in milliseconds

Range

N/A

avg_rows_sent

Double

Definition

Average rows returned

Range

N/A

max_rows_sent

Double

Definition

Maximum rows returned

Range

N/A

avg_rows_affected

Double

Definition

Average rows affected

Range

N/A

max_rows_affected

Double

Definition

Maximum rows affected

Range

N/A

avg_lock_time

Double

Definition

Average lock wait time

Range

N/A

max_lock_time

Double

Definition

Maximum lock wait time

Range

N/A

total_rows_examined

Double

Definition

Average rows scanned

Range

N/A

max_rows_examined

Double

Definition

Maximum rows scanned

Range

N/A

total_cost_ratio

String

Definition

Execution duration ratio

Range

N/A

total_examined_ratio

String

Definition

Percentage of scanned rows

Range

N/A

execute_num_ratio

String

Definition

Percentage of execution times

Range

N/A

Example Requests

POST https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/fullsql/query-sql-tpl-list 
{
    "start_at": 1763648255940,
    "end_at": 1763691455940,
    "sort": "avgCost",
    "asc": false,
    "instance_id": "bcfa975193f1402fa11a6d4fd6baf5fbin01",
    "operation": "",
    "db_name_list": [],
    "start_at": 1763648255940,
    "end_at": 1763691455940,
    "sort": "avgCost",
    "asc": false,
    "instance_id": "bcfa975193f1402fa11a6d4fd6baf5fbin01",
    "operation": "",
    "db_name_list": [],
    "keyword": "",
    "size": 50
}

Example Responses

Status code: 200

Success.

{
    "tpl_list": [
        {
            "template_id": "919257EF4DE7B678",
            "sql_template": "SELECT k.table_schema AS table_schema, k.table_name AS table_name, k.constraint_name AS constraint_name, k.column_name AS column_name, k.ordinal_position AS ordinal_position\n\t, k.referenced_table_schema AS referenced_table_schema, k.referenced_table_name AS referenced_table_name, k.referenced_column_name AS referenced_column_name, r.match_option AS match_option, r.update_rule AS update_rule\n\t, r.delete_rule AS delete_rule\nFROM information_schema.referential_constraints r\n\tJOIN information_schema.key_column_usage k\n\tON k.table_schema = r.constraint_schema\n\t\tAND k.table_name = r.table_name\n\t\tAND k.constraint_name = r.constraint_name\nWHERE r.constraint_schema = ?\n\tAND r.table_name IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
            "sql_sample_string": "/* sql from das ent */SELECT k.table_schema as table_schema, k.table_name as table_name, k.constraint_name as constraint_name, k.column_name as column_name, k.ordinal_position as ordinal_position, k.referenced_table_schema as referenced_table_schema, k.referenced_table_name as referenced_table_name,  k.referenced_column_name as referenced_column_name, r.match_option as match_option, r.update_rule as update_rule, r.delete_rule as delete_rule FROM information_schema.referential_constraints r JOIN information_schema.key_column_usage k ON k.table_schema = r.constraint_schema AND k.table_name = r.table_name AND k.constraint_name = r. constraint_name WHERE r.constraint_schema = 'testdb' AND r.table_name in ('air_quality','cs_permission_api','shopping','t_mp_forward_proxy_record','t_mp_product_apply','t_mp_product_apply_002','t_product_flow_501','student','t_datetime','t_model_config','t_table','t_table_1','t_vehicle_model','test_tb')",
            "db_names": [
                "testdb"
            ],
            "sql_type": "select",
            "db_name": "testdb",
            "execute_num": 7,
            "total_cost": 426,
            "avg_cost": 60.86,
            "max_cost": 98,
            "avg_rows_sent": 0,
            "max_rows_sent": 0,
            "avg_rows_affected": 0,
            "max_rows_affected": 0,
            "avg_lock_time": 0,
            "max_lock_time": 0,
            "total_rows_examined": 0,
            "avg_rows_examined": 0,
            "max_rows_examined": 0,
            "tunable": true,
            "total_cost_ratio": "1.14%",
            "total_examined_ratio": "0.00%",
            "execute_num_ratio": "0.07%"
        }
    ]
}

Status Codes

Status Code

Description

200

Success.

400

Client error.

500

Server error.

Error Codes

See Error Codes.