我是一位对Oracle很新的TSQL开发人员。我正在编写一个插入查询,填充此语句的SELECT对物理表和一组CTE都有各种连接。在定义我的CTE之后的SQL Server中,我可以轻松地执行INSERT并根据物理和CTE表的连接创建SELECT,如下所示:
WITH TEST AS(
SELECT VL FROM TABLE1 WHERE X = 5
),
TEST2 AS(SELECT VAL FROM TABLE4 WHERE Y =5)
INSERT INTO MYTABLE...
SELECT VAL1, VAL2,...VALN FROM TEST INNER JOIN TABLE6 ON TEST.VL =
TABLE6.VL
INNER JOIN TEST2 ON ...
INNER JOIN TABLE10
我发现此语法不适用于Oracle。尝试了社区建议的一些事情(Insert into from CTE),但似乎无法找到我正在寻找的东西......
答案 0 :(得分:1)
也许是这样的?
insert into mytable
select val1, val2, ... valn
from (select vl from table1 where x = 5) t
join table6 t6 on t6.vl = t.vl
join (select id, val from table4 where y = 5) t2 on t2.id = t.id
join table10 ...