Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

PREPARE

Focus mode
PREPARE - Amazon Athena

Creates a SQL statement with the name statement_name to be run at a later time. The statement can include parameters represented by question marks. To supply values for the parameters and run the prepared statement, use EXECUTE.

Synopsis

PREPARE statement_name FROM statement

The following table describes the parameters.

Parameter Description
statement_name The name of the statement to be prepared. The name must be unique within the workgroup.
statement A SELECT, CTAS, or INSERT INTO query.
Note

The maximum number of prepared statements in a workgroup is 1000.

Examples

The following example prepares a select query without parameters.

PREPARE my_select1 FROM SELECT * FROM nation

The following example prepares a select query that includes parameters. The values for productid and quantity will be supplied by the USING clause of an EXECUTE statement:

PREPARE my_select2 FROM SELECT order FROM orders WHERE productid = ? and quantity < ?

The following example prepares an insert query.

PREPARE my_insert FROM INSERT INTO cities_usa (city, state) SELECT city, state FROM cities_world WHERE country = ?

Additional resources

Use prepared statements

EXECUTE

DEALLOCATE PREPARE

INSERT INTO

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.