I was looking at the documentation but I haven't found the way to Drop multiple tables using wild cards.
I was trying to do something like this but it doesn't work:
DROP TABLE
TABLE_DATE_RANGE([clients.sessions_],
TIMESTAMP('2017-01-01'),
TIMESTAMP('2017-05-31'))
For dataset stats
and tables like daily_table_20181017
keeping dates conventions, I would go with simple script and gcloud Command-Line Tool:
for table in `bq ls --max_results=10000000 stats |grep TABLE |grep daily_table |awk '{print $1}'`; do echo stats.$table; bq rm -f -t stats.$table; done
DROP TABLE [table_name]; is now supported in bigquery. So here is a purely SQL/bigquery UI solution.
select concat("drop table ",table_schema,".", table_name, ";" )
from <dataset-name>.INFORMATION_SCHEMA.TABLES
where table_name like "partial_table_name%"
order by table_name desc
Audit that you are dropping the correct tables. Copy and paste back into bigquery to drop listed tables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With