Hierarchical Queries : Hierarchical Queries « Query Select « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » Query Select » Hierarchical Queries 
2. 40. 1. Hierarchical Queries

Using the CONNECT BY and START WITH Clauses

The syntax for the CONNECT BY and START WITH clauses of a SELECT statement is as follows:

SELECT [LEVEL], column, expression, ...
FROM table
[WHERE where_clause]
[[START WITH start_condition] [CONNECT BY PRIOR prior_condition]];

where

  1. LEVEL is a pseudo-column that tells you how far into a tree you are.
  2. LEVEL returns 1 for a root node, 2 for a child of the root, and so on.
  3. start_condition specifies where to start the hierarchical query from.
  4. You must specify a START WITH clause when writing a hierarchical query.
  5. An example start_condition is employee_id = 1, which specifies the query starts from employee #1.
  6. prior_condition specifies the relationship between the parent and child rows.
  7. You must specify a CONNECT BY PRIOR clause when writing a hierarchical query.

An example prior_condition is employee_id = manager_id, which specifies the relationship is between the parent employee_id and the child manager_id-that is, the child's manager_id points to the parent's employee_id.

Quote from:

Oracle Database 10g SQL (Osborne ORACLE Press Series) (Paperback)

# Paperback: 608 pages

# Publisher: McGraw-Hill Osborne Media; 1st edition (February 20, 2004)

# Language: English

# ISBN-10: 0072229810

# ISBN-13: 978-0072229813

2. 40. Hierarchical Queries
2. 40. 1. Hierarchical Queries
2. 40. 2. Using the CONNECT BY and START WITH Clauses
2. 40. 3. Formatting the Results from a Hierarchical Query
2. 40. 4. Starting at a node other than the root
2. 40. 5. Traversing Upward Through the Tree
2. 40. 6. Eliminating Nodes and Branches from a Hierarchical Query
2. 40. 7. Add where clause to a Hierarchical Query
2. 40. 8. employee tree: who is my manager
2. 40. 9. Output full path of hierarchy
2. 40. 10. sys_connect_by_path
2. 40. 11. pseudocolumn LEVEL and an example of using the levels.
2. 40. 12. pseudocolumn LEVEL and an example of using the levels with an update.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.