CmdID

CmdID / aws / aws rds-data

aws rds-data execute-statement

Runs a SQL statement against a database. AWS CLI reference

2 examples 11 options Its page in the AWS CLI reference

Opens CmdID with your command. It is read in your browser and sent nowhere.

Examples

from aws-cli, each command read by CmdID

Example 1: To execute a SQL statement that is part of a transaction

The following execute-statement example runs a SQL statement that is part of a transaction.

aws rds-data execute-statement --resource-arn "arn:aws:rds:us-west-2:123456789012:cluster:mydbcluster" --database "mydb" --secret-arn "arn:aws:secretsmanager:us-west-2:123456789012:secret:mysecret" --sql "update mytable set quantity=5 where id=201" --transaction-id "ABC1234567890xyz"Identify
--resource-arnThe Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
--databaseThe name of the database.
--secret-arnThe ARN of the secret that enables access to the DB cluster.
--sqlThe SQL statement to run.
--transaction-idThe identifier of a transaction that was started by using the BeginTransaction operation.
Its output
{
    "numberOfRecordsUpdated": 1
}

Example 2: To execute a SQL statement with parameters

The following execute-statement example runs a SQL statement with parameters.

aws rds-data execute-statement --resource-arn "arn:aws:rds:us-west-2:123456789012:cluster:mydbcluster" --database "mydb" --secret-arn "arn:aws:secretsmanager:us-west-2:123456789012:secret:mysecret" --sql "insert into mytable values (:id, :val)" --parameters "[{\"name\": \"id\", \"value\": {\"longValue\": 1}},{\"name\": \"val\", \"value\": {\"stringValue\": \"value1\"}}]"Identify
--resource-arnThe Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
--databaseThe name of the database.
--secret-arnThe ARN of the secret that enables access to the DB cluster.
--sqlThe SQL statement to run.
--parametersThe parameters for the SQL statement.
Its output
{
    "numberOfRecordsUpdated": 1
}

For more information, see Using the Data API for Aurora Serverless in the Amazon RDS User Guide.

Options

11 in the AWS CLI reference
--continue-after-timeoutA value that indicates whether to continue running the statement after the call times out.
--databaseThe name of the database.
--format-records-asA value that indicates whether to format the result set as a single JSON string.
--include-result-metadataA value that indicates whether to include metadata in the results.
--parametersThe parameters for the SQL statement.
--resource-arnThe Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
--result-set-optionsOptions that control how the result set is returned.
--schemaThe name of the database schema.
--secret-arnThe ARN of the secret that enables access to the DB cluster.
--sqlThe SQL statement to run.
--transaction-idThe identifier of a transaction that was started by using the BeginTransaction operation.