ExecuteSqlCommand

  • The ExecuteSql API is deprecated, please use the ExecuteStatement API.

Runs one or more SQL statements.

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

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { RDSDataClient, ExecuteSqlCommand } from "@aws-sdk/client-rds-data"; // ES Modules import
// const { RDSDataClient, ExecuteSqlCommand } = require("@aws-sdk/client-rds-data"); // CommonJS import
const client = new RDSDataClient(config);
const input = { // ExecuteSqlRequest
  dbClusterOrInstanceArn: "STRING_VALUE", // required
  awsSecretStoreArn: "STRING_VALUE", // required
  sqlStatements: "STRING_VALUE", // required
  database: "STRING_VALUE",
  schema: "STRING_VALUE",
};
const command = new ExecuteSqlCommand(input);
const response = await client.send(command);
// { // ExecuteSqlResponse
//   sqlStatementResults: [ // SqlStatementResults
//     { // SqlStatementResult
//       resultFrame: { // ResultFrame
//         resultSetMetadata: { // ResultSetMetadata
//           columnCount: Number("long"),
//           columnMetadata: [ // Metadata
//             { // ColumnMetadata
//               name: "STRING_VALUE",
//               type: Number("int"),
//               typeName: "STRING_VALUE",
//               label: "STRING_VALUE",
//               schemaName: "STRING_VALUE",
//               tableName: "STRING_VALUE",
//               isAutoIncrement: true || false,
//               isSigned: true || false,
//               isCurrency: true || false,
//               isCaseSensitive: true || false,
//               nullable: Number("int"),
//               precision: Number("int"),
//               scale: Number("int"),
//               arrayBaseColumnType: Number("int"),
//             },
//           ],
//         },
//         records: [ // Records
//           { // Record
//             values: [ // Row
//               { // Value Union: only one key present
//                 isNull: true || false,
//                 bitValue: true || false,
//                 bigIntValue: Number("long"),
//                 intValue: Number("int"),
//                 doubleValue: Number("double"),
//                 realValue: Number("float"),
//                 stringValue: "STRING_VALUE",
//                 blobValue: new Uint8Array(),
//                 arrayValues: [ // ArrayValueList
//                   {//  Union: only one key present
//                     isNull: true || false,
//                     bitValue: true || false,
//                     bigIntValue: Number("long"),
//                     intValue: Number("int"),
//                     doubleValue: Number("double"),
//                     realValue: Number("float"),
//                     stringValue: "STRING_VALUE",
//                     blobValue: new Uint8Array(),
//                     arrayValues: [
//                       "<Value>",
//                     ],
//                     structValue: { // StructValue
//                       attributes: "<ArrayValueList>",
//                     },
//                   },
//                 ],
//                 structValue: {
//                   attributes: "<ArrayValueList>",
//                 },
//               },
//             ],
//           },
//         ],
//       },
//       numberOfRecordsUpdated: Number("long"),
//     },
//   ],
// };

ExecuteSqlCommand Input

See ExecuteSqlCommandInput for more details

Parameter
Type
Description
awsSecretStoreArn
Required
string | undefined

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 .

dbClusterOrInstanceArn
Required
string | undefined

The ARN of the Aurora Serverless DB cluster.

sqlStatements
Required
string | undefined

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.

database
string | undefined

The name of the database.

schema
string | undefined

The name of the database schema.

ExecuteSqlCommand Output

See ExecuteSqlCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
sqlStatementResults
SqlStatementResult[] | undefined

The results of the SQL statement or statements.

Throws

Name
Fault
Details
AccessDeniedException
client

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

BadRequestException
client

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

ForbiddenException
client

There are insufficient privileges to make the call.

InternalServerErrorException
server

An internal error occurred.

ServiceUnavailableError
server

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

RDSDataServiceException
Base exception class for all service exceptions from RDSData service.