Database Reference
In-Depth Information
Figure 4.10
Using a Subquery.
4.2.8
Hierarchical Query
Typically, hierarchical queries are used to retrieve data hierarchies placed
into a single table. A common modern-day use for hierarchies is data that is
obviously hierarchical in nature. Hierarchical data has parent rows contain-
ing closely related sibling rows, such as a family tree. In our case we can use
the INSTRUMENT table in our MUSIC schema. Figure 4.11 shows a
small section of this hierarchy.
This query will read a small section of the hierarchy including and con-
tained within the Guitar node as shown in Figure 4.11. The result is shown
in Figure 4.12.
SELECT LEVEL, SECTION_ID, NAME
FROM INSTRUMENT
START WITH NAME = 'Guitar'
CONNECT BY PRIOR INSTRUMENT_ID = SECTION_ID;
Figure 4.11
The MUSIC
Schema
Instruments
Hierarchy.
Search WWH ::




Custom Search