CONNECT BY LEVEL…. ROWNUM 처럼 연속된 어떤 값들을 이끌어 낸다는.. 결과적인 것은 알겠는데..

계층형 쿼리에서는 각 노드들의 레벨을 담고 있는 가상의 열이라는 것도 뭔가 대강 느낌이 오는데..

SELECT LEVEL col FROM dual CONNECY BY LEVEL<11; 이렇게 하면 왜 저건 계층도 아닌데 LEVEL이 1씩 증가하면서

CHAT GPT 한테 물어 본 내용

In 'Oracle' which is dbms, If I want to get consecutive nubers from 1 to 10, I can write "SELECT level FROM dual CONNECT BY LEVEL < 11". but I cannnot understand how this works, even it is not a hierarchical query. can you explain?

ANSWER :

The "CONNECT BY LEVEL" clause in the above query is used to generate a series of consecutive numbers from 1 to 10.

In this case, "DUAL" is a one-row, one-column table present in Oracle which is used as a placeholder. The "LEVEL" pseudocolumn is used to keep track of the current iteration number in the sequence.

The "CONNECT BY LEVEL < 11" clause specifies the condition to end the sequence when the iteration number reaches 11. So the query generates 10 rows, each with the value of the "LEVEL" pseudocolumn incremented by 1, starting from 1.

what is ‘placeholder’ meaning?

A placeholder is a symbol, character, or value used to reserve a space for some data that will be inserted later. In programming, placeholders are often used in strings or templates to represent values that are unknown or need to be provided at a later time. They act as a placeholder for data that will be inserted into the string or template before it is used. This helps to simplify the code and make it more flexible, as the same template can be used with different data.

꽤 괜찮은 설명 (level 과 rownum의 차이)

https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9532856600346374037