All Products
Search
Document Center

Resource Management:ExecuteMultiAccountSQLQuery

Last Updated:Mar 03, 2024

Executes an SQL statement to query resources across accounts.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
ExpressionstringYes

The SQL statement to be executed.

The number of characters in the SQL statement must be less than 2,000.

For more information about the SQL syntax, see Basic SQL syntax.

SELECT * FROM resources LIMIT 100;
ScopestringYes

The search scope. The value of this parameter can be one of the following items:

  • ID of a resource directory: Resources within the management account and all members of the resource directory are searched.
  • ID of the Root folder: Resources within all members in the Root folder and the subfolders of the Root folder are searched.
  • ID of a folder: Resources within all members in the folder are searched.
  • ID of a member: Resources within the member are searched.
  • ID of a member/ID of a Resource group: Resources within the member in the resource group are searched.

For more information about how to obtain the ID of a resource directory, the Root folder, a folder, a member, or a resource group, see GetResourceDirectory , ListFoldersForParent , ListFoldersForParent , ListAccounts , or ListResourceGroups .

rd-r4****

Response parameters

ParameterTypeDescriptionExample
object

The returned result.

RequestIdstring

The request ID.

44C8A952-D6B0-5BC8-82D5-93BA02E26F2E
Columnsobject []

The columns.

Namestring

The name of the column.

resource_id
Typestring

The type of the column.

varchar
Rowsarray

An array of search results.

any

The information about the row.

[ "vsw-xxx“ ]

Examples

Sample success responses

JSONformat

{
  "RequestId": "44C8A952-D6B0-5BC8-82D5-93BA02E26F2E",
  "Columns": [
    {
      "Name": "resource_id",
      "Type": "varchar"
    }
  ],
  "Rows": [
    "[\n      \"vsw-xxx“\n]"
  ]
}

Error codes

HTTP status codeError codeError messageDescription
400NoPermissionYou are not authorized to perform this operation.You are not authorized to perform the operation.
404NotExists.ResourceDirectoryThe resource directory for the account is not enabled.No resource directory is enabled for the account.
404NotExists.ResourceDirectory.FolderIdThe specified folder does not exist.The specified folder does not exist.
409ExceedLimit.ExecuteTimeThe execution time has exceeded the limit. Please check for complex queries or large data volume, and optimize accordingly.The time consumed for the query exceeds the limit. Check and optimize the complexity of or data size in the SQL statement.
409SQLExecuteErrorFailed to execute the SQL statement.Failed to perform the query. Check whether the query statement is correct.
409InvalidSearch.SQLError: %sError: %s
409InvalidParameter.ScopeThe Scope is invalid.The Scope parameter is invalid

For a list of error codes, visit the Service error codes.