1. Trang chủ
  2. » Công Nghệ Thông Tin

Hierarchical Retrieval pdf

14 234 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Hierarchical Retrieval

  • Objectives

  • Sample Data from the EMPLOYEES Table

  • Natural Tree Structure

  • Hierarchical Queries

  • Walking the Tree

  • Slide 7

  • Walking the Tree: From the Bottom Up

  • Walking the Tree: From the Top Down

  • Ranking Rows with the LEVEL Pseudocolumn

  • Formatting Hierarchical Reports Using LEVEL and LPAD

  • Pruning Branches

  • Summary

  • Practice 19 Overview

Nội dung

19 Copyright © Oracle Corporation, 2001. All rights reserved. Hierarchical Retrieval 19-2 Copyright © Oracle Corporation, 2001. All rights reserved. Objectives After completing this lesson, you should be able to do the following: • Interpret the concept of a hierarchical query • Create a tree-structured report • Format hierarchical data • Exclude branches from the tree structure 19-3 Copyright © Oracle Corporation, 2001. All rights reserved. Sample Data from the EMPLOYEES Table 19-4 Copyright © Oracle Corporation, 2001. All rights reserved. Natural Tree Structure De Hann De Hann King King Hunold Hunold EMPLOYEE_ID = 100 (Parent) MANAGER_ID = 100 (Child) Whalen Whalen Kochhar Kochhar Higgins Higgins Mourgos Mourgos Zlotkey Zlotkey Rajs Rajs Davies Davies Matos Matos Gietz Gietz Ernst Ernst Lorentz Lorentz Hartstein Hartstein Fay Fay Abel Abel Taylor Taylor Grant Grant Vargas Vargas 19-5 Copyright © Oracle Corporation, 2001. All rights reserved. Hierarchical Queries WHERE WHERE condition condition : : expr comparison_operator expr SELECT [LEVEL], column, expr FROM table [WHERE condition(s)] [START WITH condition(s)] [CONNECT BY PRIOR condition(s)] ; 19-6 Copyright © Oracle Corporation, 2001. All rights reserved. Walking the Tree Starting Point • Specifies the condition that must be met • Accepts any valid condition Using the EMPLOYEES table, start with the employee whose last name is Kochhar. START WITH last_name = 'Kochhar' START WITH column1 = value 19-7 Copyright © Oracle Corporation, 2001. All rights reserved. Walking the Tree Direction Top down Top down Column1 = Parent Key Column1 = Parent Key Column2 = Child Key Column2 = Child Key Bottom up Bottom up Column1 = Child Key Column1 = Child Key Column2 = Parent Key Column2 = Parent Key Walk from the top down, using the Walk from the top down, using the EMPLOYEES EMPLOYEES table. table. CONNECT BY PRIOR column1 = column2 CONNECT BY PRIOR employee_id = manager_id 19-8 Copyright © Oracle Corporation, 2001. All rights reserved. Walking the Tree: From the Bottom Up SELECT employee_id, last_name, job_id, manager_id FROM employees START WITH employee_id = 101 CONNECT BY PRIOR manager_id = employee_id ; 19-9 Copyright © Oracle Corporation, 2001. All rights reserved. Walking the Tree: From the Top Down SELECT last_name||' reports to '|| PRIOR last_name "Walk Top Down" FROM employees START WITH last_name = 'King' CONNECT BY PRIOR employee_id = manager_id ; … 19-10 Copyright © Oracle Corporation, 2001. All rights reserved. Ranking Rows with the LEVEL Pseudocolumn De Hann De Hann King King Hunold Hunold Whalen Whalen Kochhar Kochhar Higgins Higgins Mourgos Mourgos Zlotkey Zlotkey Rajs Rajs Davies Davies Matos Matos Gietz Gietz Ernst Ernst Lorentz Lorentz Hartstein Hartstein Fay Fay Abel Abel Taylor Taylor Grant Grant Vargas Vargas Level 1 root/parent Level 2 parent/child Level 3 parent/child /leaf Level 4 leaf [...]... point of the query • 19-14 You can use hierarchical queries to view a hierarchical relationship between rows in a table You can eliminate nodes or branches by pruning Copyright © Oracle Corporation, 2001 All rights Practice 19 Overview This practice covers the following topics: • • • Walking through a tree • • 19-15 Distinguishing hierarchical queries from nonhierarchical queries Pruning the tree structure...Formatting Hierarchical Reports Using LEVEL and LPAD Create a report displaying company management levels, beginning with the highest level and indenting each of the following levels COLUMN org_chart FORMAT A12 SELECT . 19 Copyright © Oracle Corporation, 2001. All rights reserved. Hierarchical Retrieval 19-2 Copyright © Oracle Corporation, 2001. All rights reserved. Objectives After. the following: • Interpret the concept of a hierarchical query • Create a tree-structured report • Format hierarchical data • Exclude branches from the

Ngày đăng: 23/03/2014, 00:20

TỪ KHÓA LIÊN QUAN