ExecuteSql - RDS Data API

ExecuteSql

Runs one or more SQL statements.

Note

This operation isn't supported for Aurora PostgreSQL Serverless v2 and provisioned DB clusters, and for Aurora Serverless v1 DB clusters, the operation is deprecated. Use the BatchExecuteStatement or ExecuteStatement operation.

Request Syntax

POST /ExecuteSql HTTP/1.1 Content-type: application/json { "awsSecretStoreArn": "string", "database": "string", "dbClusterOrInstanceArn": "string", "schema": "string", "sqlStatements": "string" }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

awsSecretStoreArn

The Amazon Resource Name (ARN) of the secret that enables access to the DB cluster. Enter the database user name and password for the credentials in the secret.

For information about creating the secret, see Create a database secret.

Type: String

Length Constraints: Minimum length of 11. Maximum length of 100.

Required: Yes

database

The name of the database.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 64.

Required: No

dbClusterOrInstanceArn

The ARN of the Aurora Serverless DB cluster.

Type: String

Length Constraints: Minimum length of 11. Maximum length of 100.

Required: Yes

schema

The name of the database schema.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 64.

Required: No

sqlStatements

One or more SQL statements to run on the DB cluster.

You can separate SQL statements from each other with a semicolon (;). Any valid SQL statement is permitted, including data definition, data manipulation, and commit statements.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 65536.

Required: Yes

Response Syntax

HTTP/1.1 200 Content-type: application/json { "sqlStatementResults": [ { "numberOfRecordsUpdated": number, "resultFrame": { "records": [ { "values": [ { ... } ] } ], "resultSetMetadata": { "columnCount": number, "columnMetadata": [ { "arrayBaseColumnType": number, "isAutoIncrement": boolean, "isCaseSensitive": boolean, "isCurrency": boolean, "isSigned": boolean, "label": "string", "name": "string", "nullable": number, "precision": number, "scale": number, "schemaName": "string", "tableName": "string", "type": number, "typeName": "string" } ] } } } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

sqlStatementResults

The results of the SQL statement or statements.

Type: Array of SqlStatementResult objects

Errors

AccessDeniedException

You don't have sufficient access to perform this action.

HTTP Status Code: 403

BadRequestException

There is an error in the call or in a SQL statement. (This error only appears in calls from Aurora Serverless v1 databases.)

HTTP Status Code: 400

ForbiddenException

There are insufficient privileges to make the call.

HTTP Status Code: 403

InternalServerErrorException

An internal error occurred.

HTTP Status Code: 500

ServiceUnavailableError

The service specified by the resourceArn parameter isn't available.

HTTP Status Code: 503

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: