How to write multiple SQL statements like CREATE table in AWS Athena ( using CLI command - aws athena start-query-execution --query-string {value} )?

Viewed 6487

How to write multiple CREATE TABLE statement to execute multiple SQL statements via ATHENA CLI command - aws athena start-query-execution

I have tried this but just with single SQL statement and it works fine. But I need to run multiple SQL statements

( select count(*) from elb_logs; create external table tbl_nm; ) via CLI Athena command.

aws athena start-query-execution \
   --query-string "select count(*) from elb_logs;" \
   --query-execution-context Database=default \
   --result-configuration OutputLocation=s3://aws-athena-query-results-xxxxxxxxxx-us-east-1/ \
   --region us-east-1 \
   --output text

Should be able to execute multiple SQL statements on AWS Athena via CLI command.

1 Answers

I think you can't run several queries in one CLI command, i just tried and got this error:

    An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: 
    Only one sql statement is allowed.

Run one by one.

Related