Big Query是否支持“REPLACE INSERT”等操作或与之相关的操作?
如果我像这样运行两次查询:
INSERT INTO table(column1) VALUES(1)
它会创建一个重复的行,只有当一个具有相同值的列不存在时才可以插入一行吗?
谢谢!
答案 0 :(得分:4)
下面应该做到
#standardSQL
INSERT INTO yourTable(column1)
SELECT value FROM (SELECT 1 AS value)
LEFT JOIN yourTable
ON column1 = value
WHERE column1 IS NULL
答案 1 :(得分:3)
这对你有用吗?
INSERT INTO table(column1)
WITH s AS (SELECT 1 src)
SELECT src FROM s WHERE NOT EXISTS (
SELECT * FROM table t WHERE t.column1 = s.src
)