Internet Info, s.r.o. Lupa Měšec Podnikatel Root Zdroják DigiZone Slunečnice Vitalia TopDrive KupDnes Navrcholu NovýTarif Dobrý web Weblogy Woko Jagg Computer.cz SK: MojeLinky

Hlavní navigace

Vlákno názorů k článku
Modelování databází

Zdenek Jager
Zdenek Jager (neregistrovaný)
3. 4. 2002 15:14

Prochazeni stromu

Jen by me zajimalo: prochazeni stromem nasledujicim SQL prikazem je specialita DB Oracle? Nebo jde o standard?
SELECT name, id, id_top
FROM tree
CONNECT BY PRIOR id = id_top --- vazba ve stromu
START WITH name = 'FIRST';

vojtech
vojtech (neregistrovaný)
3. 4. 2002 17:02

Re: Prochazeni stromu

je to specialita oracle. imho se nejedna o nejake lepsi reseni, ale jen o zjednoduseni syntaxe... (nebo se pletu?)

Zdenek Jager
Zdenek Jager (neregistrovaný)
3. 4. 2002 18:41

Re: Prochazeni stromu

Ne, neni to zjednoduseni syntaxe. Ani nevim, jak bych totez v SQL napsal jinak.

Karel Zak
Karel Zak (neregistrovaný)
4. 4. 2002 11:10

Re: Prochazeni stromu

V nekterem materialu k Oracle jsem to videl trefne pojmenovane jako WALK TREE. Pokud je mi znamo tak jina DB nez Oracle tuto vlastnost primo na urovni SQL neimplementuje a ani standard nic takovaho neobsahuje. Ostatne SQL jako takove je nerekurzivni. Obavam ze, ze i to prochazeni strumu bude uvnitr Oracle implementovano jak mnoho selectu. Jine reseni mne moc nenapada, snad jen nejak specialne delane indexy, kere v sobe zahrnuji danou hierarchii. Jinak viz. docs k Oracle8:
Oracle uses the information from the above clause to form the hierarchy using the following steps:

1. Oracle selects the root row(s) of the hierarchy-those rows that satisfy the condition of the START WITH clause.
2. Oracle selects the child rows of each root row. Each child row must satisfy the condition of the CONNECT BY clause with respect to one of the root rows.
3. Oracle selects successive generations of child rows. Oracle first selects the children of the rows returned in step 2 , and then the children of those children, and so on. Oracle always selects children by evaluating the CONNECT BY condition with respect to a current parent row.
4. If the query contains a WHERE clause, Oracle eliminates all rows from the hierarchy that do not satisfy the condition of the WHERE clause. Oracle evaluates this condition for each row individually, rather than removing all the children of a row that does not satisfy the condition.

Zasílat nově přidané příspěvky e-mailem