Skip to content Skip to sidebar Skip to footer

How To Use Delete And Insert Simultaneously In Query Script

I am using Google BigQuery(Uses Standard SQL) but I have a Table with some data. Based on the data in the Table, I want to insert fake messages rows to that table, and after that,

Solution 1:

If you are worried about accidentally deleting data, I would create a view that combines your actual data with your fake data.

CREATEVIEW project.dataset.my_view
ASselect message from project.dataset.actual_table 
UNIONALLselect'This is a fake message 1'as message
UNIONALLselect'This is a fake message 2'as message

You can query against this view without changing underlying data, and when you are done, simply delete the view. Much safer than playing around with important data if you aren't crystal clear on what you are doing.

Post a Comment for "How To Use Delete And Insert Simultaneously In Query Script"