curl --request POST \
--url https://api.example.com/v1/instances/{instance}/databases/{database}:query \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"dataSourceId": "<string>",
"statement": "<string>",
"limit": 123,
"explain": true,
"schema": "<string>",
"queryOption": {
"redisRunCommandsOn": "REDIS_RUN_COMMANDS_ON_UNSPECIFIED",
"mssqlExplainFormat": "MSSQL_EXPLAIN_FORMAT_UNSPECIFIED"
},
"container": "<string>"
}
'{
"results": [
{
"columnNames": [
"<string>"
],
"columnTypeNames": [
"<string>"
],
"rows": [
{
"values": [
{
"nullValue": "NULL_VALUE",
"boolValue": true,
"bytesValue": "<string>",
"doubleValue": 123,
"floatValue": 123,
"int32Value": 123,
"int64Value": "<string>",
"stringValue": "<string>",
"uint32Value": 123,
"uint64Value": "<string>",
"valueValue": "<unknown>",
"timestampValue": {
"googleTimestamp": "2023-11-07T05:31:56Z",
"accuracy": 123
},
"timestampTzValue": {
"googleTimestamp": "2023-11-07T05:31:56Z",
"zone": "<string>",
"offset": 123,
"accuracy": 123
}
}
]
}
],
"rowsCount": "<string>",
"error": "<string>",
"latency": "<string>",
"statement": "<string>",
"postgresError": {
"severity": "<string>",
"code": "<string>",
"message": "<string>",
"detail": "<string>",
"hint": "<string>",
"position": 123,
"internalPosition": 123,
"internalQuery": "<string>",
"where": "<string>",
"schemaName": "<string>",
"tableName": "<string>",
"columnName": "<string>",
"dataTypeName": "<string>",
"constraintName": "<string>",
"file": "<string>",
"line": 123,
"routine": "<string>"
},
"syntaxError": {
"startPosition": {
"line": 123,
"column": 123
}
},
"permissionDenied": {
"resources": [
"<string>"
],
"commandType": "COMMAND_TYPE_UNSPECIFIED"
},
"messages": [
{
"level": "LEVEL_UNSPECIFIED",
"content": "<string>"
}
],
"masked": [
{
"semanticTypeId": "<string>",
"semanticTypeTitle": "<string>",
"maskingRuleId": "<string>",
"algorithm": "<string>",
"context": "<string>",
"classificationLevel": "<string>",
"semanticTypeIcon": "<string>"
}
]
}
]
}Executes a read-only SQL query against a database. Permissions required: bb.databases.get
curl --request POST \
--url https://api.example.com/v1/instances/{instance}/databases/{database}:query \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"dataSourceId": "<string>",
"statement": "<string>",
"limit": 123,
"explain": true,
"schema": "<string>",
"queryOption": {
"redisRunCommandsOn": "REDIS_RUN_COMMANDS_ON_UNSPECIFIED",
"mssqlExplainFormat": "MSSQL_EXPLAIN_FORMAT_UNSPECIFIED"
},
"container": "<string>"
}
'{
"results": [
{
"columnNames": [
"<string>"
],
"columnTypeNames": [
"<string>"
],
"rows": [
{
"values": [
{
"nullValue": "NULL_VALUE",
"boolValue": true,
"bytesValue": "<string>",
"doubleValue": 123,
"floatValue": 123,
"int32Value": 123,
"int64Value": "<string>",
"stringValue": "<string>",
"uint32Value": 123,
"uint64Value": "<string>",
"valueValue": "<unknown>",
"timestampValue": {
"googleTimestamp": "2023-11-07T05:31:56Z",
"accuracy": 123
},
"timestampTzValue": {
"googleTimestamp": "2023-11-07T05:31:56Z",
"zone": "<string>",
"offset": 123,
"accuracy": 123
}
}
]
}
],
"rowsCount": "<string>",
"error": "<string>",
"latency": "<string>",
"statement": "<string>",
"postgresError": {
"severity": "<string>",
"code": "<string>",
"message": "<string>",
"detail": "<string>",
"hint": "<string>",
"position": 123,
"internalPosition": 123,
"internalQuery": "<string>",
"where": "<string>",
"schemaName": "<string>",
"tableName": "<string>",
"columnName": "<string>",
"dataTypeName": "<string>",
"constraintName": "<string>",
"file": "<string>",
"line": 123,
"routine": "<string>"
},
"syntaxError": {
"startPosition": {
"line": 123,
"column": 123
}
},
"permissionDenied": {
"resources": [
"<string>"
],
"commandType": "COMMAND_TYPE_UNSPECIFIED"
},
"messages": [
{
"level": "LEVEL_UNSPECIFIED",
"content": "<string>"
}
],
"masked": [
{
"semanticTypeId": "<string>",
"semanticTypeTitle": "<string>",
"maskingRuleId": "<string>",
"algorithm": "<string>",
"context": "<string>",
"classificationLevel": "<string>",
"semanticTypeIcon": "<string>"
}
]
}
]
}The name is the instance name to execute the query against. Format: instances/{instance}/databases/{databaseName}
The id of data source. It is used for querying admin data source even if the instance has read-only data sources. Or it can be used to query a specific read-only data source.
The SQL statement to execute.
The maximum number of rows to return.
Explain the statement.
The default schema to search objects. Equals to the current schema in Oracle and search path in Postgres.
Show child attributes
Container is the container name to execute the query against, used for CosmosDB only.
OK
The query results.
Show child attributes
Was this page helpful?