View a markdown version of this page

Use DeleteNamedQuery with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DeleteNamedQuery with an AWS SDK or CLI

The following code examples show how to use DeleteNamedQuery.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code examples:

CLI
AWS CLI

To delete a named query

The following delete-named-query example deletes the named query that has the specified ID.

aws athena delete-named-query \ --named-query-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111

This command produces no output.

For more information, see Running SQL Queries Using Amazon Athena in the Amazon Athena User Guide.

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

def delete_named_query(self, named_query_id: str) -> None: """ Deletes a named query by its ID. :param named_query_id: The unique ID of the named query to delete. :raises ClientError: If the named query could not be deleted. """ try: self.athena_client.delete_named_query(NamedQueryId=named_query_id) logger.info("Deleted named query '%s'.", named_query_id) except ClientError as err: if err.response["Error"]["Code"] == "InvalidRequestException": logger.error( "Invalid request deleting named query '%s'. " "The named query ID was not found or is invalid. %s: %s", named_query_id, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise
  • For API details, see DeleteNamedQuery in AWS SDK for Python (Boto3) API Reference.