如何在 BigQuery 中 UNION 所有表名满足条件的表?
How to UNION ALL tables with tablename satisfying condition in BigQuery?
我可以通过以下方式统一两个表:
select * from project.dataset.ourtable1
union all
select * from project.dataset.ourtable2
但是如果我有数千个表,并且我想统一所有名称以 ourtable
开头的表怎么办?
我可以通过以下方式获取所有此类表格:
select table_id from project.dataset.__TABLES__
where starts_with(table_id,'ourtable')
其中 returns 一列 table_id
以 ourtable
开头的表格。
如何对所有这些执行 union all
?
重新表述问题:我正在寻找
的等价物
select * from project.dataset.ourtable1
union all
select * from project.dataset.ourtable2
union all
.
.
.
union all
select * from project.dataset.ourtable9999
在 BigQuery 中。
一个类似的线程:,但它是针对 SQL-Server,而不是 BQ。
您可以使用 wildcard:
select * from `project.dataset.ourtable*`
我可以通过以下方式统一两个表:
select * from project.dataset.ourtable1
union all
select * from project.dataset.ourtable2
但是如果我有数千个表,并且我想统一所有名称以 ourtable
开头的表怎么办?
我可以通过以下方式获取所有此类表格:
select table_id from project.dataset.__TABLES__
where starts_with(table_id,'ourtable')
其中 returns 一列 table_id
以 ourtable
开头的表格。
如何对所有这些执行 union all
?
重新表述问题:我正在寻找
的等价物select * from project.dataset.ourtable1
union all
select * from project.dataset.ourtable2
union all
.
.
.
union all
select * from project.dataset.ourtable9999
在 BigQuery 中。
一个类似的线程:
您可以使用 wildcard:
select * from `project.dataset.ourtable*`