oracle PL/SQL 中是否存在像 Common Table Expressions 这样的东西?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3335366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:06:48  来源:igfitidea点击:

Does something like Common Table Expressions exist in PL/SQL?

sqlsql-serveroracle

提问by Matthew Hoenstine

I recently learned about CTE's in SQL Server and am attempting to use it in PL/SQL. I do not need the recurive benefits of it, however, I would like to use it in lieu of creating a view and to improve query performance. Just looking for some direction on what code may be similar.

我最近了解了 SQL Server 中的 CTE,并试图在 PL/SQL 中使用它。我不需要它的递归好处,但是,我想用它代替创建视图并提高查询性能。只是寻找一些关于哪些代码可能相似的方向。

回答by Tony Andrews

In Oracle this is known as subquery factoring, and it works the same as in SQL Server AFAIK:

在 Oracle 中,这称为子查询分解,它的工作方式与 SQL Server AFAIK 中的相同:

with cte as (select * from emp)
select * from cte join dept on dept.deptno = cte.deptno;

See SELECT documentationand search for "factoring".

请参阅SELECT 文档并搜索“factoring”。