Oracle 11g Release 1 (11.1) SQL _ hierarchical query (details)

Source: Internet
Author: User

Content

  • HR Mode
  • Oracle sample Schema
  • Install HR Mode
  • Demo level Query
  • Hierarchical Query
  • Reference
HR mode Oracle sample Schema

Oracle has several examplesSchema, Including,HR (Human Resources),OE (Order Entry),OC (Online Catalog),PM (Product Media),IX (Information Exchange)AndSH (Sales History). These schemas have dependencies. Together is a complete database. For more information, see http://docs.oracle.com/cd/b28359_01/server.111/b28328/toc.htm#begin.

You can install these schemas as follows:

  • Use Database Configuration Assistant)
  • Manual Installation
  • Use the mksample. SQL script to reset the instance to its initial state.
Install HR Mode

This article demonstrates how to useHRMode. See examplesHRMode script, andHRObjects and tables in the schema. Manual InstallationHRMode. For more information, see.

 

Demo level Query

Example 1: DemoCONNECT. UseCONNECTTo define the relationship between employees and managers.

SELECT employee_id, last_name, manager_id
   FROM employees
   CONNECT BY PRIOR employee_id = manager_id;

 

(Not all results .)

Example 2: DemoLEVEL. This example is the same as Example 1. Just usedLEVELPseudo column.

SELECT employee_id, last_name, manager_id, LEVEL
   FROM employees
   CONNECT BY PRIOR employee_id = manager_id;

(Not all results .)

Example 3: DemoSTART. UseSTARTClause to specify the level of root data rows and useORDER SIBLINGSMaintain the order in the hierarchy.

Not all results. InHr. employeesTable, employee Steven King is the highest position in the company. In the preceding result:

  • 1
  • 2
  • 3
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.