I am using to BigQuery web UI for running my queries. I want to delete some specific rows from all tables in a Dataset. I want to do it by running all delete queries in one go, like below:
DELETE FROM `dataset_name.tabl_name_1` WHERE REGEXP_CONTAINS(user_dim.user_id, r'g_1478_h_1.') = TRUE;
DELETE FROM `dataset_name.tabl_name_2` WHERE REGEXP_CONTAINS(user_dim.user_id, r'g_1478_h_1.') = TRUE;
DELETE FROM `dataset_name.tabl_name_3` WHERE REGEXP_CONTAINS(user_dim.user_id, r'g_1478_h_1.') = TRUE
There are almost 500 tables. So there will be 500 queries to be run in one go. I have unchecked the option of 'use Legacy Sql'.
But on running above queries (almost 500) returns error:
Syntax error: Unexpected keyword DELETE at [2:1]
Is there any solution to my problem?
You cannot do this in BigQuery web UI!
Your best option here is to use BigQuery client
of your preference and script those repetitive statements
Have in mind quotas/limitation
for DML
Edit (October 2019):
Support for scripting and stored procedures is now in beta. You can submit multiple statements separated with semi-colons and BigQuery is able to run them now.
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