amazon web services – How to delete / drop multiple tables in AWS athena?

amazon web services – How to delete / drop multiple tables in AWS athena?

You can use aws-cli batch-delete-table to delete multiple table at once.

aws glue batch-delete-table 
--database-name <database-name> 
--tables-to-delete <table1-name> <table2-name> <table3-name> ...

You are correct. It is not possible to run multiple queries in the one request.

An alternative is to create the tables in a specific database. Dropping the database will then cause all the tables to be deleted.

For example:

CREATE DATABASE foo;
CREATE EXTERNAL TABLE bar1 ...;
CREATE EXTERNAL TABLE bar2 ...;
DROP DATABASE foo CASCADE;

The DROP DATABASE command will delete the bar1 and bar2 tables.

amazon web services – How to delete / drop multiple tables in AWS athena?

You can use AWS Glue interface to do this now. The prerequisite being you must upgrade to AWS Glue Data Catalog.

If you Upgrade to the AWS Glue Data Catalog from Athena, the metadata for tables created in Athena is visible in Glue and you can use the AWS Glue UI to check multiple tables and delete them at once.

FAQ on Upgrading data catalog: https://docs.aws.amazon.com/athena/latest/ug/glue-faq.html

Leave a Reply

Your email address will not be published.