Is there a way to mass delete multiple tables? - activelearner
In bash, you can do something like:
for i in $(bq ls -n 9999 my_dataset | grep keyword | awk '{print $1}'); do bq rm -ft my_dataset.$i; done;
Explanation:
bq ls -n 9999 my_dataset - list of up to 9999 tables in my dataset| grep keyword | grep keyword - transfer the results of the previous command to grep, find a keyword that has common tables.| awk '{print $1}' | awk '{print $1}' - pass the results of the previous command to awk and print only the first column- Wrap it all in a for loop
do bq rm -ft my_dataset.$i; done; - delete each table from your data set
I highly recommend running the commands to list the tables you want to delete before adding "do bq rm". This way you can make sure that you only delete the tables that you want to delete.
source share