Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create temporary table in Google BigQuery

Is there any way to create a temporary table in Google BigQuery through:

SELECT * INTO <temp table> 
FROM <table name> 

same as we can create in SQL?

For complex queries, I need to create temporary tables to store my data.

like image 688
Vasundhara Avatar asked Dec 19 '13 05:12

Vasundhara


People also ask

Can we create temporary table in BigQuery?

Temporary and permanent tables BigQuery uses temporary tables to cache query results that aren't written to a permanent table. The tables are created in a special dataset and named randomly. You can also create temporary tables for your own use.

Can you create tables in BigQuery?

You can create a table in BigQuery in the following ways: Manually using the Google Cloud console or the bq command-line tool bq mk command. Programmatically by calling the tables.

How do I create a snapshot table in BigQuery?

Create a table snapshot using time travel. In the console, go to the BigQuery page. In the Explorer pane, expand the project and dataset nodes of the table you want to snapshot. Click the name of the table you want to snapshot.


1 Answers

2019 update -- With BigQuery scripting (Beta now), CREATE TEMP TABLE is officially supported. See public documentation here.

2018 update: https://stackoverflow.com/a/50227484/132438

Every query in bigquery creates a temporary table with the results. Temporary unless you give a name to the destination table, then you are in control of its lifecycle.

Use the api to see the temporary table name, or name your tables when querying.

like image 57
Felipe Hoffa Avatar answered Oct 17 '22 22:10

Felipe Hoffa