This guide will walk you through how to delete multiple BigQuery tables using a wildcard. This solution was provided by Henry Munro at Stack Overflow.
- Copy this code:
select concat("bq rm -f -t ",table_schema,".", table_name, ";" )
where table_name like "INSERT_YOUR_TABLE_NAME_%"
order by table_name desc
- Open BigQuery. Paste in the copied code.
- Replace <insert_your_dataset_name> with your dataset name. In this example, we’ve used “Supermetrics”.
- Replace INSERT_YOUR_TABLE_NAME_% with your table name. Here, we’ve used "GA_GA_V1".
- Click Run.
- Near the bottom of the screen, click Save results. This will open the Save Query Results dialog box.
- Select Google Sheets from the dropdown menu.
- Click Save.
- Open your file in Google Sheets, and copy the query from it.
- Paste it into BigQuery.
- Make sure to add /* at both the beginning and the end of the code.
Once you've commented out the original code, run the query and it'll remove your tables.