Using saved queries - Amazon Athena

Using saved queries

You can use the Athena console to save, edit, run, rename, and delete the queries that you create in the query editor.

Considerations and limitations

  • You can update the name, description, and query text of saved queries.

  • You can only update the queries in your own account.

  • You cannot change the workgroup or database to which the query belongs.

  • Athena does not keep a history of query modifications. If you want to keep a particular version of a query, save it with a different name.

Working with saved queries in the Athena console

To save a query and give it a name

  1. In the Athena console query editor, enter or run a query.

  2. At the bottom of the query editor window, choose Save, Save as.

  3. In the Save query dialog box, enter a name for the query and an optional description. You can use the expandable Preview SQL query window to verify the contents of the query before you save it.

  4. Choose Save.

    In the query editor, the tab for the query shows the name that you specified.

To run a saved query

  1. In the Athena console, choose the Saved queries tab.

  2. In the Saved queries list, choose the name of the query that you want to run.

    The query editor displays the query that you chose.

  3. Choose Run.

To rename a saved query

  1. In the Athena console, choose the Saved queries tab.

  2. Select the check box for the query that you want to rename.

  3. Choose Rename.

  4. In the Rename query dialog box, edit the query name and query description. You can use the expandable Preview SQL query window to verify the contents of the query before you rename it.

  5. Choose Rename query.

    The renamed query appears in the Saved queries list.

To edit a saved query

  1. In the Athena console, choose the Saved queries tab.

  2. In the Saved queries list, choose the name of the query that you want to edit.

  3. Edit the query in the query editor.

  4. Perform one of the following steps:

    • To run the query, choose Run.

    • To save the query, choose Save, Save.

    • To save the query with a different name, choose Save, Save as.

To delete a saved query

  1. In the Athena console, choose the Saved queries tab.

  2. Select one or more check boxes for the queries that you want to delete.

  3. Choose Delete.

  4. In the Delete saved queries prompt, choose Delete.

    The queries are removed from the Saved queries list.

Using the Athena API to update saved queries

For information about using the Athena API to update a saved query, see the UpdateNamedQuery action in the Athena API Reference.