gpt4 book ai didi

go - BigQuery 中的表联接

转载 作者:数据小太阳 更新时间:2023-10-29 03:13:52 26 4
gpt4 key购买 nike

你知道有没有办法连接两个表,因为例如,在 MySQL 中使用外键约束(我似乎没有找到关于这个的任何信息)?如果没有,是否有替代品?

谢谢!

最佳答案

我对你的问题的解释如下 -

Is there a way to limit the values that can be used on the tableX to only the IDs that exist on the tableY? For example via using a foreign key constraint like in MySQL!

BigQuery 不提供任何直接机制来实现这种情况。
但是您可以轻松地自己实现这一目标。

例如,假设您需要向 tableX 中插入一些数据,但您希望确保只有那些行将被插入到新数据中 id 所在的位置在 tableY

因此,您可以通过以下查询“执行”此操作

#standardSQL
SELECT n.*
FROM newData AS n
JOIN tableY AS y
ON n.id = y.id

...您可以使用 tableX 作为目标运行此查询,并且只会插入需要的行

希望你有一个想法

您还可以检查现有的相关功能请求 -
https://issuetracker.google.com/issues/35906045
https://issuetracker.google.com/issues/35906043

关于go - BigQuery 中的表联接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42983018/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com