Saving SQL Query Results in Google BigQuery

When we run a SQL query in Google BigQuery this query returns results according to our query. Now we have to save these results, So how to do that ?

Saving  SQL Query Results in Google BigQuery

There are several ways to save query results . When we run a query this will create a temporary table of our results. This table is available only for 24 hours . We can change the expiration time of this temporary table by going to -

Job Information > Destination table Temporary table > DETAILS > EDIT DETAILS > Expiration Time > SAVE

Otherwise we can SAVE RESULTS or EXPLORE DATA in Google Data Studio .

I have two tables, supermarket_female and supermarket_male . I have appended both tables with some selected columns - City, Customer_type, Gender, Rating . I have runned this query -

SELECT City, Customer_type, Gender, Rating FROM `trydata.supermarketsales.supermarket_female`
UNION ALL
SELECT City, Customer_type, Gender, Rating FROM `trydata.supermarketsales.supermarket_male`

This query returns me some results and now i can save these results in these of the ways -

CSV (Google Drive) [Save upto 1 GB of results to Google Drive]

By this method we can save upto 1 GB of results in our google drive as CSV file.

CSV (local file) [Save upto 16000 rows locally]

By selecting this way we can save upto 16000 rows of results in our local system as CSV file.

JSON (Google Drive) [Save upto 1 GB of results to Google Drive]

By this method we can save upto 1 GB of results in our google drive as JSON format file.

JSON (local file) [Save upto 16000 rows locally]

By selecting this method we can save upto 16000 rows of results in our local system as JSON file.

BigQuery Table (Save results as a BigQuery table)

By selecting this method we can save our results in a BigQuery table. In this method we can save results in different projects or dataset. There is an option of entering the table name in this dialog box which creates the same table in the selected dataset with results in it.

Save results as a BigQuery table

Google Sheets [Save upto 16000 rows to Google Sheets]

By this method we can save upto 16000 rows results in google sheets .

Copy to Clipboard [Copy upto 16000 rows to Clipboard ]

By this method we can copy upto 16000 rows results in our clipboard .

1 comment:

  1. Hi, I am doing data cleaning in BQ. Saving result for an individual query is not a problem, but how do I save the result of all queries I've executed in one table?

    ReplyDelete

Pages