假设我已经创建了table3,并尝试使用以下代码将数据插入其中
WITH table1
AS
(SELECT 1 AS key, 'One' AS value),
table2
AS
(SELECT 1 AS key, 'I' AS value)
INSERT TABLE table3
SELECT t1.key, t1.value, t2.value
FROM table1 t1
JOIN table2 t2
ON (t1.key = t2.key)
但是,我遇到了一个错误,因为无法识别select子句中的输入"insert">如果我只是删除插入语句,那么查询运行得很好。
这是语法问题吗?或者我不能用with子句插入?
根据需要使用INTO或OVERWRITE:
INSERT INTO TABLE table3 --this will append data, keeping the existing data intact
或
INSERT OVERWRITE TABLE table3 --will overwrite any existing data
阅读手册:从查询将数据插入配置单元表