简体   繁体   English

从 BigQuery 表中获取计划数据到另一个 BigQuery 表(计划查询)

[英]Fetch Schedule data from a BigQuery Table to another BigQuery Table (Scheduled queries)

I am really new to GCP and I am trying to Query in a GCP BigQuery to fetch all data from one BigQuery table and Insert all into another BigQuery table我对GCP真的很陌生,我正在尝试在GCP BigQueryQuery以从一个BigQuery table中获取所有数据并将所有数据插入another BigQuery table

I am trying the Following query where Project 1 & Dataset.Table1 is the Project where I am trying to read the data.我正在尝试以下查询,其中Project 1 & Dataset.Table1是我尝试读取数据的项目。 and Project 2 and Dataset2.Table2 is the Table where I am trying to Insert all the data with the same NamingProject 2Dataset2.Table2是我试图插入具有相同命名的所有数据的表

SELECT * FROM `Project1.DataSet1.Table1` LIMIT 1000
insert  INTO `Project2.Dataset2.Table2`

But am I receiving a query error message?但我是否收到查询错误消息?

Does anyone know how to solve this issue?有谁知道如何解决这个问题?

There may be a couple of comments...可能有几个评论...

  1. The syntax might be different => insert into table select and so on - see DML statements in the standard SQL语法可能不同 => insert into table select等等 - 请参阅标准 SQL 中的 DML 语句

  2. Such approach of data coping might not be very optimal considering time and cost.考虑到时间和成本,这种数据处理方法可能不是非常理想的。 It might be better to use bq cp -f... commands - see BigQuery Copy — How to copy data efficiently between BigQuery environments and bq command-line tool reference - if that is possible in your case.使用bq cp -f...命令可能会更好 - 请参阅BigQuery Copy - 如何在 BigQuery 环境bq 命令行工具参考之间有效复制数据 - 如果在您的情况下可能的话。

The correct syntax of the query is as suggested by @al-dann.查询的正确语法由@al-dann 建议。 I will try to explain further with a sample query as below:我将尝试通过如下示例查询进一步解释:

Query :查询

insert into `Project2.Dataset2.Table2`
select * from `Project1.DataSet1.Table1`

Input Table :输入表

在此处输入图像描述

This will insert values into the second table as below:这会将值插入到第二个表中,如下所示:

Output Table : Output 表

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM