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. Above the query editor window, on the tab for the query, choose the three vertical dots, and then choose 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 query.

    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 ID of the query that you want to run.

    The query editor displays the query that you chose.

  3. Choose Run.

To edit a saved query
  1. In the Athena console, choose the Saved queries tab.

  2. In the Saved queries list, choose the ID 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 the three vertical dots on the tab for the query, and then choose Save.

    • To save the query with a different name, choose the three vertical dots on the tab for the query, and then choose Save as.

To rename or delete a saved query already displayed in the query editor
  1. Choose the three vertical dots on the tab for the query, and then choose Rename or Delete.

  2. Follow the prompts to rename or delete the query.

To rename a saved query not displayed in the query editor
  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 delete a saved query not displayed in the query editor
  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. At the confirmation prompt, choose Delete.

    One or more 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.