如何在 Google BigQuery 中创建临时表 [英] How to create temporary table in Google BigQuery

查看:46
本文介绍了如何在 Google BigQuery 中创建临时表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过以下方式在 Google BigQuery 中创建临时表:

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

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

和我们在 SQL 中创建的一样吗?

same as we can create in SQL?

对于复杂的查询,我需要创建临时表来存储我的数据.

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

推荐答案

2018 更新 - DDL 的最终答案

借助 BigQuery 的 DDL 支持,您可以根据查询结果创建表 - 并在创建时指定其到期时间.例如,3 天:

With BigQuery's DDL support you can create a table from the results a query - and specify its expiration at creation time. For example, for 3 days:

#standardSQL
CREATE TABLE `fh-bigquery.public_dump.vtemp`
OPTIONS(
  expiration_timestamp=TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 3 DAY)
) AS
SELECT corpus, COUNT(*) c
FROM `bigquery-public-data.samples.shakespeare`
GROUP BY corpus

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆