LEVEL is not a table column but a pseudocolumn automatically supplied by Oracle Database (and some compatible dialects) when a query includes a hierarchical clause (CONNECT BY). It counts how many parent-child traversals were required to reach the current row, starting at 1 for the root nodes identified in START WITH. Because it is computed at runtime, LEVEL cannot be updated or indexed. It is evaluated after the CONNECT BY logic, so filtering on LEVEL in a WHERE clause acts on the generated hierarchy, while filtering in a CONNECT BY clause influences the recursion itself. LEVEL is available only in statements that actually contain CONNECT BY, hierarchical subquery factoring USING NOCYCLE CONNECT BY, or recursive subquery factoring constructs that Oracle internally rewrites to a CONNECT BY plan.
CONNECT BY, START WITH, SYS_CONNECT_BY_PATH, NOCYCLE, recursive CTE (WITH RECURSIVE), hierarchical queries
Oracle7 Database (1992)
LEVEL shows how deep a row is in the hierarchy produced by CONNECT BY. A value of 1 is a root row, 2 is its child, 3 is a grandchild, and so forth.
No. LEVEL is Oracle specific. Other systems rely on recursive CTEs where you must explicitly calculate a depth column.
Yes. Add a WHERE clause such as WHERE LEVEL <= 3 to restrict the output after the hierarchy is built.
It is primarily for SELECT. Using LEVEL in INSERT or UPDATE statements without a hierarchical SELECT subquery will cause an error.