AWS CLI를 사용하여 준비된 문 생성 - Amazon Athena

AWS CLI를 사용하여 준비된 문 생성

AWS CLI를 사용해 준비된 문을 작성하는 데 다음 athena 명령 중 하나를 사용할 수 있습니다.

  • create-prepared-statement 명령을 사용하고 실행 파라미터가 있는 쿼리 문을 제공합니다.

  • start-query-execution 명령을 사용하고 PREPARE 구문을 사용하는 쿼리 문자열을 제공합니다.

create-prepared-statement 사용

create-prepared-statement 명령에서 다음 예제와 같이 query-statement 인수에 쿼리 텍스트를 정의합니다.

aws athena create-prepared-statement --statement-name PreparedStatement1 --query-statement "SELECT * FROM table WHERE x = ?" --work-group athena-engine-v2

start-query-execution 및 PREPARE 구문 사용

start-query-execution 명령을 사용합니다. 다음 예제와 같이 query-string 인수에 PREPARE 문을 넣습니다.

aws athena start-query-execution --query-string "PREPARE PreparedStatement1 FROM SELECT * FROM table WHERE x = ?" --query-execution-context '{"Database": "default"}' --result-configuration '{"OutputLocation": "s3://amzn-s3-demo-bucket/..."}'