Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running multiple queries in BigQuery web UI

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?

like image 229
Anjum Avatar asked Mar 06 '23 09:03

Anjum


1 Answers

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.

like image 197
Mikhail Berlyant Avatar answered Apr 29 '23 08:04

Mikhail Berlyant