Amazon Athena
User Guide  | API Reference

Queries and Query Result Files

You query Amazon S3 data using the Athena Query Editor. You can write DDL statements to create and modify Athena tables, and to run SQL queries on Athena tables. Athena supports ANSI SQL standard queries.

Athena stores query results in Amazon S3 automatically. Each query that you run has a results file in CSV format (*.csv), and a metadata file (*.csv.metadata) that includes header information, such as column type. If necessary, you can access the result files to work with them.

Note

You can delete metadata files (*.csv.metadata) without causing errors, but important information about the query is lost.

Query files are saved in an Amazon S3 location based on the name of the query and the date the query ran, as follows:

{QueryLocation}/{QueryName|Unsaved}/{yyyy}/{mm}/{dd}/{QueryID}/

  • QueryLocation is the base location for all query results. To view or change this location, choose Settings. You can enter a new value for Query result location at any time. You can also choose to encrypt query results in Amazon S3. For more information, see Configuring Encryption Options.
  • QueryName is the name of the query for which the results are saved. If the query wasn't saved, Unsaved appears. To see a list of queries and examine their SQL statements, choose Saved queries.
  • yyyy/mm/dd/ is the date the query ran.
  • QueryID is the unique ID of the query.