How to delete multiple BigQuery tables

This guide will walk you through how to delete multiple BigQuery tables by using a wildcard. 

This solution was provided by Henry Munro at Stackoverflow


1. Copy this code: 

select concat("bq rm -f -t ",table_schema,".",   table_name, ";" )
from <insert_your_dataset_name>.INFORMATION_SCHEMA.TABLES
where table_name like "INSERT_YOUR_TABLE_NAME_%"
order by table_name desc

2. Paste this code to BigQuery: https://console.cloud.google.com/bigquery



3. Replace <insert_your_dataset_name> to your dataset name, for example, "Supermetrics".





4. Replace INSERT_YOUR_TABLE_NAME_% to your table name, for example, "GA_GA_V1".




5. Click on run to proceed. 



6. Click on save results.


7. Export your file into Google Sheets


8. Click on save



9. Copy the query from Google Sheets. 



9. Paste the query from Google Sheets to BigQuery. 




10. Be aware to add

 /* at the beginning of the code &

 /* to the end of the code

Once you have commented out the original code, you can run the query and it will remove your tables.


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.