什么是 Oracle 中的级别伪列,谁能解释一下?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3103872/
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 20:54:01  来源:igfitidea点击:

What is a level pseudo column in Oracle, Can anyone explain me in this?

sqloracle

提问by user338292

What is a level pseudo column in Oracle, Can anyone explain me in this?

什么是 Oracle 中的级别伪列,谁能解释一下?

回答by Gabriel Magana

You use LEVEL with the SELECT CONNECT BY statement to organize rows from a database table into a tree structure. LEVEL returns the level number of a node in a tree structure. The root is level 1, children of the root are level 2, grandchildren are level 3, and so on.

您可以将 LEVEL 与 SELECT CONNECT BY 语句一起使用,以将数据库表中的行组织成树结构。LEVEL 返回树结构中节点的级别编号。根为 1 级,根的子代为 2 级,孙子为 3 级,依此类推。

In the START WITH clause, you specify a condition that identifies the root of the tree. You specify the direction in which the query walks the tree (down from the root or up from the branches) with the PRIOR operator.

在 START WITH 子句中,指定标识树根的条件。您可以使用 PRIOR 运算符指定查询遍历树的方向(从根向下或从分支向上)。

回答by UltraCommit

    SELECT LEVEL N
      FROM DUAL
CONNECT BY LEVEL < 76;

The previous statement generates all the integers starting from 1 and ending to 75. It uses the LEVEL pseudocolumn.

前面的语句生成从 1 到 75 的所有整数。它使用 LEVEL 伪列。