What is connect by level in oracle
Level is nothing but it’s a Pseudocolumn column in oracle
which is used in a hierarchical query to identify the hierarchy level
(parent->child) in numeric format.
How to Print 1 to 10 in a SQL Query :
Here is simple query to print 1 to 10 in sql by
using dual table and connect by leve.
Below is the sql query :
SELECT
level
FROM
DUAL
CONNECT BY
level
<=10;
Below is the output of the above query :
There is another way to print 1 to 10 by using Union.
Below is the SQL query to print 1 to 10 by using Union :
SELECT 1 FROM DUAL
Union
SELECT 2 FROM DUAL
Union
SELECT 3 FROM DUAL
Union
SELECT 4 FROM DUAL
Union
SELECT 5 FROM DUAL
Union
SELECT 6 FROM DUAL
Union
SELECT 7 FROM DUAL
Union
SELECT 8 FROM DUAL
Union
SELECT 9 FROM DUAL
Union
SELECT 10 FROM DUAL;