This document discusses hierarchical retrieval and queries on hierarchical data. It covers interpreting hierarchical queries, creating tree-structured reports, formatting hierarchical data using indentation to show levels, and excluding branches from the tree structure using pruning. Sample data from an EMPLOYEES table is used to demonstrate hierarchical queries that walk the tree from the top down and bottom up, rank rows using the LEVEL pseudocolumn, and format reports in an indented structure. The document also notes how to prune branches from the results using the WHERE and CONNECT BY clauses.
This document discusses hierarchical retrieval and querying hierarchical data. It provides examples of using hierarchical queries to walk through a tree structure and format hierarchical data. Key aspects covered include specifying the starting point and direction of a hierarchical query, using the LEVEL pseudocolumn to rank and indent rows, and pruning branches from the tree. The goal is to interpret and work with hierarchical data using SQL.
This document discusses restricting and sorting data in SQL queries. It covers limiting rows using the WHERE clause with comparison, BETWEEN, IN, LIKE, and NULL conditions. Logical operators like AND, OR, and NOT are also covered. The ORDER BY clause is discussed for sorting query results in ascending or descending order by one or multiple columns. Examples are provided for each concept to illustrate their proper usage in SELECT statements.
1. The document discusses using ROLLUP and CUBE operations to produce subtotal and cross-tabulation values from grouped data.
2. It also covers using the GROUPING function to identify rows created by ROLLUP or CUBE, and using GROUPING SETS to define multiple groupings in a single query for improved efficiency.
3. The techniques described include composite columns, concatenated grouping sets, and combining GROUP BY expressions in various ways.
This document discusses techniques for manipulating large data sets, including:
1. Using subqueries to copy data between tables, update rows based on other tables, and delete rows matching conditions in other tables.
2. Performing different types of multitable INSERT statements like unconditional, conditional ALL, conditional FIRST, and pivoting to insert data into multiple tables.
3. Using the MERGE statement to conditionally insert or update rows by matching conditions between tables.
4. Tracking changes to data over time using flashback queries to view past versions of rows.
This document discusses different types of subqueries in SQL, including:
1) Multiple-column subqueries that return more than one column and can be used for pairwise or nonpairwise comparisons.
2) Correlated subqueries that are executed once for each row of the outer query to return different results.
3) Scalar subqueries that return a single value and can be used in conditions, expressions, and clauses like ORDER BY.
4) EXISTS operator subqueries to check for existence of rows in the results set.
5) WITH clause to define subqueries that can be referenced multiple times.
This document discusses different types of joins in SQL, including:
1) Equijoins to retrieve records that match between two tables using column equality.
2) Nonequijoins using operators like BETWEEN to join on non-equal columns.
3) Outer joins to return both matching and non-matching record results from the left or right tables.
4) Self-joins to join a table to itself.
5) Cross joins to generate the Cartesian product between two tables without a join condition.
This document describes several extensions to DML and DDL statements in Oracle9i:
1) Multitable INSERT statements allow inserting rows into multiple tables in a single statement. Types include unconditional INSERT, conditional ALL INSERT, conditional FIRST INSERT, and pivoting INSERT.
2) External tables allow querying data stored outside the database in flat files using SQL. Metadata is defined using CREATE TABLE with the external_table_clause.
3) Indexes can be created at the same time as tables using the CREATE INDEX syntax within the CREATE TABLE statement.
This document discusses hierarchical retrieval and querying hierarchical data. It provides examples of using hierarchical queries to walk through a tree structure and format hierarchical data. Key aspects covered include specifying the starting point and direction of a hierarchical query, using the LEVEL pseudocolumn to rank and indent rows, and pruning branches from the tree. The goal is to interpret and work with hierarchical data using SQL.
This document discusses restricting and sorting data in SQL queries. It covers limiting rows using the WHERE clause with comparison, BETWEEN, IN, LIKE, and NULL conditions. Logical operators like AND, OR, and NOT are also covered. The ORDER BY clause is discussed for sorting query results in ascending or descending order by one or multiple columns. Examples are provided for each concept to illustrate their proper usage in SELECT statements.
1. The document discusses using ROLLUP and CUBE operations to produce subtotal and cross-tabulation values from grouped data.
2. It also covers using the GROUPING function to identify rows created by ROLLUP or CUBE, and using GROUPING SETS to define multiple groupings in a single query for improved efficiency.
3. The techniques described include composite columns, concatenated grouping sets, and combining GROUP BY expressions in various ways.
This document discusses techniques for manipulating large data sets, including:
1. Using subqueries to copy data between tables, update rows based on other tables, and delete rows matching conditions in other tables.
2. Performing different types of multitable INSERT statements like unconditional, conditional ALL, conditional FIRST, and pivoting to insert data into multiple tables.
3. Using the MERGE statement to conditionally insert or update rows by matching conditions between tables.
4. Tracking changes to data over time using flashback queries to view past versions of rows.
This document discusses different types of subqueries in SQL, including:
1) Multiple-column subqueries that return more than one column and can be used for pairwise or nonpairwise comparisons.
2) Correlated subqueries that are executed once for each row of the outer query to return different results.
3) Scalar subqueries that return a single value and can be used in conditions, expressions, and clauses like ORDER BY.
4) EXISTS operator subqueries to check for existence of rows in the results set.
5) WITH clause to define subqueries that can be referenced multiple times.
This document discusses different types of joins in SQL, including:
1) Equijoins to retrieve records that match between two tables using column equality.
2) Nonequijoins using operators like BETWEEN to join on non-equal columns.
3) Outer joins to return both matching and non-matching record results from the left or right tables.
4) Self-joins to join a table to itself.
5) Cross joins to generate the Cartesian product between two tables without a join condition.
This document describes several extensions to DML and DDL statements in Oracle9i:
1) Multitable INSERT statements allow inserting rows into multiple tables in a single statement. Types include unconditional INSERT, conditional ALL INSERT, conditional FIRST INSERT, and pivoting INSERT.
2) External tables allow querying data stored outside the database in flat files using SQL. Metadata is defined using CREATE TABLE with the external_table_clause.
3) Indexes can be created at the same time as tables using the CREATE INDEX syntax within the CREATE TABLE statement.
XML is a markup language that allows users to define their own tags and structure for documents. It separates content from formatting and is extensible, platform-independent, and human-readable. Well-formed XML documents follow syntax rules like having matching open and close tags and properly nested elements. Valid XML documents also comply with constraints defined in their associated DTD. Common XML components include elements, attributes, namespaces, comments, and CDATA sections.
This document provides an overview of XML (Extensible Markup Language) including:
- The basic structure and components of an XML document including elements, attributes, entities, and advanced components.
- An example well-commented XML document.
- The basic rules for creating a well-formed XML document including being case sensitive, requiring start and end tags, proper nesting, and more.
- Common errors in element naming and how to avoid them.
- How to walk through modifying an example XML document to add new elements and ensure it remains well-formed.
XML (Extensible Markup Language) allows users to define their own customized markup languages to structure data. It was created as a simplified version of SGML to make it usable on the web. XML is important because it removes constraints of HTML and allows for richer content than HTML alone. XML will enable easier exchange of data between businesses and applications.
XML is a markup language that allows users to define their own tags and structure for documents. It separates content from formatting and is extensible, platform-independent, and human-readable. Well-formed XML documents follow syntax rules like having matching open and close tags and properly nested elements. Valid XML documents also comply with constraints defined in their associated DTD. Common XML components include elements, attributes, namespaces, comments, and CDATA sections.
This document provides an overview of XML (Extensible Markup Language) including:
- The basic structure and components of an XML document including elements, attributes, entities, and advanced components.
- An example well-commented XML document.
- The basic rules for creating a well-formed XML document including being case sensitive, requiring start and end tags, proper nesting, and more.
- Common errors in element naming and how to avoid them.
- How to add new elements and attributes to an example XML document to ensure it remains well-formed.
XML stands for Extensible Markup Language and is used to mark up data so it can be processed by computers, whereas HTML is used to mark up text to be displayed for users. Both XML and HTML use elements enclosed in tags, attributes, and entities, but XML only describes content while HTML describes both structure and appearance. XML allows users to define their own tags, and is strictly structured, making it suitable for data processing by computers.
This document provides an overview of XML, including its basic structure and components. XML documents use elements to structure and tag content. Elements must be properly nested within a single root element and can have attributes. The relationships between these elements form a tree structure. XML documents also support comments, processing instructions, and character encoding. CSS and XSLT can be used to display and transform XML for web users. While databases are better for structured data, XML is well suited for loosely structured or large records.
The document provides an introduction to shell scripting basics in UNIX/Linux. It discusses what a shell and shell script are, introduces the popular bash shell, and covers running commands, variables, logic, and other shell scripting concepts. The key points covered include:
- A shell is a program that takes commands and runs other programs. Popular shells include bash, csh, tcsh, and ksh.
- A shell script is a text file containing shell commands that is executable. Creating and running a simple "Hello world" script is demonstrated.
- Running commands, pipes, redirection, variables, logic, and flow control like if/else, for loops are explained.
- Useful bash
This document provides an introduction and overview of the Unix operating system. It covers topics such as getting help, the file system, the shell, network security, email clients, text editors, input/output redirection, printing, process management, and the X window system. The document is intended to help new Unix users understand basic Unix concepts and commands.
Linux is an open source operating system created by Linus Torvalds in 1991. It uses a Linux kernel and includes many common Unix tools. Linux is free to use and modify due to its open source licensing. It runs on many hardware platforms and is growing in popularity for servers, desktops, and embedded systems due to its low cost, stability, and security. Users can download Linux from distributions like Red Hat which package the Linux kernel with additional software and support.
After completing this section, students should be able to log into the Linux system, understand and manipulate the UNIX file system, describe the role of the shell, use basic file commands like cd, ls, cp, and rm, use standard input/output and piping, and understand the UNIX philosophy. The document provides an introduction to UNIX operating systems, shells, file systems, basic commands, and input/output redirection.
This document provides an overview of the C programming language, including its history, characteristics, and syntax. C was developed in the 1970s alongside Unix and became widely used for system programming. It allows for close interaction with the operating system and hardware. The document walks through a simple "Hello World" program to demonstrate C's syntax, including preprocessing, compilation, linking, and execution. It also provides a more complex guessing game example to illustrate additional C language features like variables, operators, conditionals, and loops.
This document provides an introduction to the C programming language. It discusses key concepts like functions, variables, data types, memory, scopes, expressions, operators, control flow with if/else statements and loops. It also explains how passing arguments by value means functions cannot directly modify their parameters, but passing addresses allows modifying variables in the calling scope. Overall it serves as a helpful primer on basic C syntax and programming concepts for newcomers to the language.
This document provides an overview of introductory concepts in C programming, including simple programs to print text and perform arithmetic. It covers basic syntax like comments, functions, variables, data types, operators, input/output, and conditional statements. Memory concepts are introduced, as well as the preprocessor, standard libraries, and control flow structures like if/else. Examples are provided to demonstrate printing text, taking user input, performing calculations, and making decisions based on relational comparisons.
This document provides an introduction to C programming over 13 pages. It covers the purpose and schedule of the lectures, differences between C and Java, C program structure, keywords, variables, data types, and more. The main points are that the lectures will provide a crash course in C with an emphasis on differences from Java, cover practical examples and topics related to C programming, and include history, language overview, pointers, memory management, compiling and debugging.
This document provides an introduction to programming in C. It begins by discussing computers, hardware, software, data, and information processing. It then discusses what programming is and how to approach solving problems through programming. The document outlines the major components of a C program and provides a first example program. It also covers key C programming concepts like variables, data types, expressions, control flow, functions, pointers, arrays, strings, structures, files and memory allocation. The document is intended to introduce readers to programming in C from a high level.
The document provides an overview of the C programming language. It begins with a brief history of C and how it evolved from the B programming language to support UNIX. It describes C as a systems programming language that is close to hardware but with higher-level constructs than assembly. The rest of the document outlines key C language concepts like data types, variables, operators, functions, and control structures. It provides examples of how to use basic programming elements like if/else statements and switch statements.
This document contains repeated text about printing or viewing notes pages for a preface rather than slides. It provides instructions to print or view notes pages for a preface section eight separate times without any other notable information.
This document provides an overview and objectives for a course on Oracle database administration. It covers topics such as controlling user access, managing schema objects, manipulating large data sets, generating reports, managing data in different time zones, retrieving data using subqueries, hierarchical retrieval, and regular expression support. Each chapter provides learning objectives and exercises for students to reinforce the concepts covered.
Regular expressions can be used in SQL to search, match, and replace strings. Key regular expression functions include REGEXP_INSTR, REGEXP_SUBSTR, and REGEXP_REPLACE. Meta characters like *, +, and [] are used to define patterns to match. For example, 'a+' would match one or more occurrences of 'a' in a string.
XML is a markup language that allows users to define their own tags and structure for documents. It separates content from formatting and is extensible, platform-independent, and human-readable. Well-formed XML documents follow syntax rules like having matching open and close tags and properly nested elements. Valid XML documents also comply with constraints defined in their associated DTD. Common XML components include elements, attributes, namespaces, comments, and CDATA sections.
This document provides an overview of XML (Extensible Markup Language) including:
- The basic structure and components of an XML document including elements, attributes, entities, and advanced components.
- An example well-commented XML document.
- The basic rules for creating a well-formed XML document including being case sensitive, requiring start and end tags, proper nesting, and more.
- Common errors in element naming and how to avoid them.
- How to walk through modifying an example XML document to add new elements and ensure it remains well-formed.
XML (Extensible Markup Language) allows users to define their own customized markup languages to structure data. It was created as a simplified version of SGML to make it usable on the web. XML is important because it removes constraints of HTML and allows for richer content than HTML alone. XML will enable easier exchange of data between businesses and applications.
XML is a markup language that allows users to define their own tags and structure for documents. It separates content from formatting and is extensible, platform-independent, and human-readable. Well-formed XML documents follow syntax rules like having matching open and close tags and properly nested elements. Valid XML documents also comply with constraints defined in their associated DTD. Common XML components include elements, attributes, namespaces, comments, and CDATA sections.
This document provides an overview of XML (Extensible Markup Language) including:
- The basic structure and components of an XML document including elements, attributes, entities, and advanced components.
- An example well-commented XML document.
- The basic rules for creating a well-formed XML document including being case sensitive, requiring start and end tags, proper nesting, and more.
- Common errors in element naming and how to avoid them.
- How to add new elements and attributes to an example XML document to ensure it remains well-formed.
XML stands for Extensible Markup Language and is used to mark up data so it can be processed by computers, whereas HTML is used to mark up text to be displayed for users. Both XML and HTML use elements enclosed in tags, attributes, and entities, but XML only describes content while HTML describes both structure and appearance. XML allows users to define their own tags, and is strictly structured, making it suitable for data processing by computers.
This document provides an overview of XML, including its basic structure and components. XML documents use elements to structure and tag content. Elements must be properly nested within a single root element and can have attributes. The relationships between these elements form a tree structure. XML documents also support comments, processing instructions, and character encoding. CSS and XSLT can be used to display and transform XML for web users. While databases are better for structured data, XML is well suited for loosely structured or large records.
The document provides an introduction to shell scripting basics in UNIX/Linux. It discusses what a shell and shell script are, introduces the popular bash shell, and covers running commands, variables, logic, and other shell scripting concepts. The key points covered include:
- A shell is a program that takes commands and runs other programs. Popular shells include bash, csh, tcsh, and ksh.
- A shell script is a text file containing shell commands that is executable. Creating and running a simple "Hello world" script is demonstrated.
- Running commands, pipes, redirection, variables, logic, and flow control like if/else, for loops are explained.
- Useful bash
This document provides an introduction and overview of the Unix operating system. It covers topics such as getting help, the file system, the shell, network security, email clients, text editors, input/output redirection, printing, process management, and the X window system. The document is intended to help new Unix users understand basic Unix concepts and commands.
Linux is an open source operating system created by Linus Torvalds in 1991. It uses a Linux kernel and includes many common Unix tools. Linux is free to use and modify due to its open source licensing. It runs on many hardware platforms and is growing in popularity for servers, desktops, and embedded systems due to its low cost, stability, and security. Users can download Linux from distributions like Red Hat which package the Linux kernel with additional software and support.
After completing this section, students should be able to log into the Linux system, understand and manipulate the UNIX file system, describe the role of the shell, use basic file commands like cd, ls, cp, and rm, use standard input/output and piping, and understand the UNIX philosophy. The document provides an introduction to UNIX operating systems, shells, file systems, basic commands, and input/output redirection.
This document provides an overview of the C programming language, including its history, characteristics, and syntax. C was developed in the 1970s alongside Unix and became widely used for system programming. It allows for close interaction with the operating system and hardware. The document walks through a simple "Hello World" program to demonstrate C's syntax, including preprocessing, compilation, linking, and execution. It also provides a more complex guessing game example to illustrate additional C language features like variables, operators, conditionals, and loops.
This document provides an introduction to the C programming language. It discusses key concepts like functions, variables, data types, memory, scopes, expressions, operators, control flow with if/else statements and loops. It also explains how passing arguments by value means functions cannot directly modify their parameters, but passing addresses allows modifying variables in the calling scope. Overall it serves as a helpful primer on basic C syntax and programming concepts for newcomers to the language.
This document provides an overview of introductory concepts in C programming, including simple programs to print text and perform arithmetic. It covers basic syntax like comments, functions, variables, data types, operators, input/output, and conditional statements. Memory concepts are introduced, as well as the preprocessor, standard libraries, and control flow structures like if/else. Examples are provided to demonstrate printing text, taking user input, performing calculations, and making decisions based on relational comparisons.
This document provides an introduction to C programming over 13 pages. It covers the purpose and schedule of the lectures, differences between C and Java, C program structure, keywords, variables, data types, and more. The main points are that the lectures will provide a crash course in C with an emphasis on differences from Java, cover practical examples and topics related to C programming, and include history, language overview, pointers, memory management, compiling and debugging.
This document provides an introduction to programming in C. It begins by discussing computers, hardware, software, data, and information processing. It then discusses what programming is and how to approach solving problems through programming. The document outlines the major components of a C program and provides a first example program. It also covers key C programming concepts like variables, data types, expressions, control flow, functions, pointers, arrays, strings, structures, files and memory allocation. The document is intended to introduce readers to programming in C from a high level.
The document provides an overview of the C programming language. It begins with a brief history of C and how it evolved from the B programming language to support UNIX. It describes C as a systems programming language that is close to hardware but with higher-level constructs than assembly. The rest of the document outlines key C language concepts like data types, variables, operators, functions, and control structures. It provides examples of how to use basic programming elements like if/else statements and switch statements.
This document contains repeated text about printing or viewing notes pages for a preface rather than slides. It provides instructions to print or view notes pages for a preface section eight separate times without any other notable information.
This document provides an overview and objectives for a course on Oracle database administration. It covers topics such as controlling user access, managing schema objects, manipulating large data sets, generating reports, managing data in different time zones, retrieving data using subqueries, hierarchical retrieval, and regular expression support. Each chapter provides learning objectives and exercises for students to reinforce the concepts covered.
Regular expressions can be used in SQL to search, match, and replace strings. Key regular expression functions include REGEXP_INSTR, REGEXP_SUBSTR, and REGEXP_REPLACE. Meta characters like *, +, and [] are used to define patterns to match. For example, 'a+' would match one or more occurrences of 'a' in a string.
SATTA MATKA DPBOSS KALYAN MATKA RESULTS KALYAN CHART KALYAN MATKA MATKA RESULT KALYAN MATKA TIPS SATTA MATKA MATKA COM MATKA PANA JODI TODAY BATTA SATKA MATKA PATTI JODI NUMBER MATKA RESULTS MATKA CHART MATKA JODI SATTA COM INDIA SATTA MATKA MATKA TIPS MATKA WAPKA ALL MATKA RESULT LIVE ONLINE MATKA RESULT KALYAN MATKA RESULT DPBOSS MATKA 143 MAIN MATKA KALYAN MATKA RESULTS KALYAN CHART
SATTA MATKA DPBOSS KALYAN MATKA RESULTS KALYAN CHART KALYAN MATKA MATKA RESULT KALYAN MATKA TIPS SATTA MATKA MATKA COM MATKA PANA JODI TODAY BATTA SATKA MATKA PATTI JODI NUMBER MATKA RESULTS MATKA CHART MATKA JODI SATTA COM INDIA SATTA MATKA MATKA TIPS MATKA WAPKA ALL MATKA RESULT LIVE ONLINE MATKA RESULT KALYAN MATKA RESULT DPBOSS MATKA 143 MAIN MATKA KALYAN MATKA RESULTS KALYAN CHART
SATTA MATKA DPBOSS KALYAN MATKA RESULTS KALYAN CHART KALYAN MATKA MATKA RESULT KALYAN MATKA TIPS SATTA MATKA MATKA COM MATKA PANA JODI TODAY BATTA SATKA MATKA PATTI JODI NUMBER MATKA RESULTS MATKA CHART MATKA JODI SATTA COM INDIA SATTA MATKA MATKA TIPS MATKA WAPKA ALL MATKA RESULT LIVE ONLINE MATKA RESULT KALYAN MATKA RESULT DPBOSS MATKA 143 MAIN MATKA KALYAN MATKA RESULTS KALYAN CHART INDIA MATKA KALYAN SATTA MATKA 420 INDIAN MATKA SATTA KING MATKA FIX JODI FIX FIX FIX SATTA NAMBAR MATKA INDIA SATTA BATTA
The Steadfast and Reliable Bull: Taurus Zodiac Signmy Pandit
Explore the steadfast and reliable nature of the Taurus Zodiac Sign. Discover the personality traits, key dates, and horoscope insights that define the determined and practical Taurus, and learn how their grounded nature makes them the anchor of the zodiac.
Cover Story - China's Investment Leader - Dr. Alyce SUmsthrill
In World Expo 2010 Shanghai – the most visited Expo in the World History
https://www.britannica.com/event/Expo-Shanghai-2010
China’s official organizer of the Expo, CCPIT (China Council for the Promotion of International Trade https://en.ccpit.org/) has chosen Dr. Alyce Su as the Cover Person with Cover Story, in the Expo’s official magazine distributed throughout the Expo, showcasing China’s New Generation of Leaders to the World.
Efficient PHP Development Solutions for Dynamic Web ApplicationsHarwinder Singh
Unlock the full potential of your web projects with our expert PHP development solutions. From robust backend systems to dynamic front-end interfaces, we deliver scalable, secure, and high-performance applications tailored to your needs. Trust our skilled team to transform your ideas into reality with custom PHP programming, ensuring seamless functionality and a superior user experience.
Satta matka fixx jodi panna all market dpboss matka guessing fixx panna jodi kalyan and all market game liss cover now 420 matka office mumbai maharashtra india fixx jodi panna
Call me 9040963354
WhatsApp 9040963354
SATTA MATKA DPBOSS KALYAN MATKA RESULTS KALYAN CHART KALYAN MATKA MATKA RESULT KALYAN MATKA TIPS SATTA MATKA MATKA COM MATKA PANA JODI TODAY BATTA SATKA MATKA PATTI JODI NUMBER MATKA RESULTS MATKA CHART MATKA JODI SATTA COM INDIA SATTA MATKA MATKA TIPS MATKA WAPKA ALL MATKA RESULT LIVE ONLINE MATKA RESULT KALYAN MATKA RESULT DPBOSS MATKA 143 MAIN MATKA KALYAN MATKA RESULTS KALYAN CHART
SATTA MATKA DPBOSS KALYAN MATKA RESULTS KALYAN CHART KALYAN MATKA MATKA RESULT KALYAN MATKA TIPS SATTA MATKA MATKA COM MATKA PANA JODI TODAY BATTA SATKA MATKA PATTI JODI NUMBER MATKA RESULTS MATKA CHART MATKA JODI SATTA COM INDIA SATTA MATKA MATKA TIPS MATKA WAPKA ALL MATKA RESULT LIVE ONLINE MATKA RESULT KALYAN MATKA RESULT DPBOSS MATKA 143 MAIN MATKA KALYAN MATKA RESULTS KALYAN CHART
The report *State of D2C in India: A Logistics Update* talks about the evolving dynamics of the d2C landscape with a particular focus on how brands navigate the complexities of logistics. Third Party Logistics enablers emerge indispensable partners in facilitating the growth journey of D2C brands, offering cost-effective solutions tailored to their specific needs. As D2C brands continue to expand, they encounter heightened operational complexities with logistics standing out as a significant challenge. Logistics not only represents a substantial cost component for the brands but also directly influences the customer experience. Establishing efficient logistics operations while keeping costs low is therefore a crucial objective for brands. The report highlights how 3PLs are meeting the rising demands of D2C brands, supporting their expansion both online and offline, and paving the way for sustainable, scalable growth in this fast-paced market.
4. Natural Tree Structure De Haan King Hunold EMPLOYEE_ID = 100 (Parent) MANAGER_ID = 100 (Child) Whalen Kochhar Higgins Mourgos Zlotkey Rajs Davies Matos Gietz Ernst Lorentz Hartstein Fay Abel Taylor Grant Vargas
5.
6.
7.
8. 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 ;
9. 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 ; …
10. Ranking Rows with the LEVEL Pseudocolumn Level 1 root/parent Level 3 parent/child /leaf Level 4 leaf De Haan King Hunold Whalen Kochhar Higgins Mourgos Zlotkey Rajs Davies Matos Gietz Ernst Lorentz Hartstein Fay Abel Taylor Grant Vargas
13. Pruning Branches Use the WHERE clause to eliminate a node. Use the CONNECT BY clause to eliminate a branch. WHERE last_name != 'Higgins' CONNECT BY PRIOR employee_id = manager_id AND last_name != 'Higgins' Kochhar Higgins Gietz Whalen Kochhar Higgins Whalen Gietz
14.
15.
16.
17.
18.
Editor's Notes
Oracle Database 10 g : SQL Fundamentals II 7 - Objectives In this lesson, you learn how to use hierarchical queries to create tree-structured reports.
Oracle Database 10 g : SQL Fundamentals II 7 - Sample Data from the EMPLOYEES Table Using hierarchical queries, you can retrieve data based on a natural hierarchical relationship between rows in a table. A relational database does not store records in a hierarchical way. However, where a hierarchical relationship exists between the rows of a single table, a process called tree walking enables the hierarchy to be constructed. A hierarchical query is a method of reporting, the branches of a tree in a specific order. Imagine a family tree with the eldest members of the family found close to the base or trunk of the tree and the youngest members representing branches of the tree. Branches can have their own branches, and so on. A hierarchical query is possible when a relationship exists between rows in a table. For example, on the slide, you see that employees with the job IDs of AD_VP , ST_MAN , SA_MAN , and MK_MAN report directly to the president of the company. We know this because the MANAGER_ID column of these records contains the employee ID 100, which belongs to the president ( AD_PRES ). Note: Hierarchical trees are used in various fields such as human genealogy (family trees), livestock (breeding purposes), corporate management (management hierarchies), manufacturing (product assembly), evolutionary research (species development), and scientific research.
Oracle Database 10 g : SQL Fundamentals II 7 - Natural Tree Structure The EMPLOYEES table has a tree structure representing the management reporting line. The hierarchy can be created by looking at the relationship between equivalent values in the EMPLOYEE_ID and MANAGER_ID columns. This relationship can be exploited by joining the table to itself. The MANAGER_ID column contains the employee number of the employee’s manager. The parent-child relationship of a tree structure enables you to control: The direction in which the hierarchy is walked The starting point inside the hierarchy Note: The slide displays an inverted tree structure of the management hierarchy of the employees in the EMPLOYEES table.
Oracle Database 10 g : SQL Fundamentals II 7 - Keywords and Clauses Hierarchical queries can be identified by the presence of the CONNECT BY and START WITH clauses. In the syntax: SELECT Is the standard SELECT clause LEVEL For each row returned by a hierarchical query, the LEVEL pseudocolumn returns 1 for a root row, 2 for a child of a root, and so on. FROM table Specifies the table, view, or snapshot containing the columns. You can select from only one table. WHERE Restricts the rows returned by the query without affecting other rows of the hierarchy condition Is a comparison with expressions START WITH Specifies the root rows of the hierarchy (where to start). This clause is required for a true hierarchical query. CONNECT BY Specifies the columns in which the relationship between parent and child PRIOR rows exist. This clause is required for a hierarchical query. The SELECT statement cannot contain a join or query from a view that contains a join.
Oracle Database 10 g : SQL Fundamentals II 7 - Walking the Tree The row or rows to be used as the root of the tree are determined by the START WITH clause. The START WITH clause can be used in conjunction with any valid condition. Examples Using the EMPLOYEES table, start with King, the president of the company. ... START WITH manager_id IS NULL Using the EMPLOYEES table, start with employee Kochhar. A START WITH condition can contain a subquery. ... START WITH employee_id = (SELECT employee_id FROM employees WHERE last_name = 'Kochhar' ) If the START WITH clause is omitted, the tree walk is started with all of the rows in the table as root rows. If a WHERE clause is used, the walk is started with all the rows that satisfy the WHERE condition. This no longer reflects a true hierarchy. Note: The clauses CONNECT BY PRIOR and START WITH are not ANSI SQL standard.
Oracle Database 10 g : SQL Fundamentals II 7 - Walking the Tree (continued) The direction of the query, whether it is from parent to child or from child to parent, is determined by the CONNECT BY PRIOR column placement. The PRIOR operator refers to the parent row. To find the child rows of a parent row, the Oracle server evaluates the PRIOR expression for the parent row and the other expressions for each row in the table. Rows for which the condition is true are the child rows of the parent. The Oracle server always selects child rows by evaluating the CONNECT BY condition with respect to a current parent row. Examples Walk from the top down using the EMPLOYEES table. Define a hierarchical relationship in which the EMPLOYEE_ID value of the parent row is equal to the MANAGER_ID value of the child row. ... CONNECT BY PRIOR employee_id = manager_id Walk from the bottom up using the EMPLOYEES table. ... CONNECT BY PRIOR manager_id = employee_id The PRIOR operator does not necessarily need to be coded immediately following the CONNECT BY . Thus, the following CONNECT BY PRIOR clause gives the same result as the one in the preceding example. ... CONNECT BY employee_id = PRIOR manager_id Note: The CONNECT BY clause cannot contain a subquery.
Oracle Database 10 g : SQL Fundamentals II 7 - Walking the Tree: From the Bottom Up The example on the slide displays a list of managers starting with the employee whose employee ID is 101. Example In the following example, EMPLOYEE_ID values are evaluated for the parent row and MANAGER_ID , and SALARY values are evaluated for the child rows. The PRIOR operator applies only to the EMPLOYEE_ID value. ... CONNECT BY PRIOR employee_id = manager_id AND salary > 15000; To qualify as a child row, a row must have a MANAGER_ID value equal to the EMPLOYEE_ID value of the parent row and must have a SALARY value greater than $15,000.
Oracle Database 10 g : SQL Fundamentals II 7 - Walking the Tree: From the Top Down Walking from the top down, display the names of the employees and their manager. Use employee King as the starting point. Print only one column.
Oracle Database 10 g : SQL Fundamentals II 7 - Ranking Rows with the LEVEL Pseudocolumn You can explicitly show the rank or level of a row in the hierarchy by using the LEVEL pseudocolumn. This will make your report more readable. The forks where one or more branches split away from a larger branch are called nodes, and the very end of a branch is called a leaf, or leaf node. The diagram on the slide shows the nodes of the inverted tree with their LEVEL values. For example, employee Higgens is a parent and a child, whereas employee Davies is a child and a leaf. The LEVEL Pseudocolumn On the slide, King is the root or parent ( LEVEL = 1 ). Kochhar, De Haan, Mourgos, Zlotkey, Hartstein, Higgens, and Hunold are children and also parents ( LEVEL = 2 ). Whalen, Rajs, Davies, Matos, Vargas, Gietz, Ernst, Lorentz, Abel, Taylor, Grant, and Fay are children and leaves. ( LEVEL = 3 and LEVEL = 4 ) Note: A root node is the highest node within an inverted tree. A child node is any nonroot node. A parent node is any node that has children. A leaf node is any node without children. The number of levels returned by a hierarchical query may be limited by available user memory.
Oracle Database 10 g : SQL Fundamentals II 7 - Formatting Hierarchical Reports Using LEVEL The nodes in a tree are assigned level numbers from the root. Use the LPAD function in conjunction with the pseudocolumn LEVEL to display a hierarchical report as an indented tree. In the example on the slide: LPAD( char1 , n [, char2 ]) returns char1 , left-padded to length n with the sequence of characters in char2 . The argument n is the total length of the return value as it is displayed on your terminal screen. LPAD(last_name, LENGTH(last_name)+(LEVEL*2)-2,'_') defines the display format. char1 is the LAST_NAME , n the total length of the return value, is length of the LAST_NAME +(LEVEL*2)-2 , and char2 is '_' . In other words, this tells SQL to take the LAST_NAME and left-pad it with the '_' character until the length of the resultant string is equal to the value determined by LENGTH(last_name)+(LEVEL*2)-2 . For King, LEVEL = 1 . Therefore, (2 * 1) – 2 = 2 – 2 = 0. So King does not get padded with any '_' character and is displayed in column 1. For Kochhar, LEVEL = 2 . Therefore, (2 * 2) – 2 = 4 – 2 = 2 . So Kochhar gets padded with 2 '_' characters and is displayed indented. The rest of the records in the EMPLOYEES table are displayed similarly.
Oracle Database 10 g : SQL Fundamentals II 7 - Formatting Hierarchical Reports Using LEVEL (continued) …
Oracle Database 10 g : SQL Fundamentals II 7 - Pruning Branches You can use the WHERE and CONNECT BY clauses to prune the tree; that is, to control which nodes or rows are displayed. The predicate you use acts as a Boolean condition. Examples Starting at the root, walk from the top down, and eliminate employee Higgins in the result, but process the child rows. SELECT department_id, employee_id,last_name, job_id, salary FROM employees WHERE last_name != 'Higgins' START WITH manager_id IS NULL CONNECT BY PRIOR employee_id = manager_id; Starting at the root, walk from the top down, and eliminate employee Higgins and all child rows. SELECT department_id, employee_id,last_name, job_id, salary FROM employees START WITH manager_id IS NULL CONNECT BY PRIOR employee_id = manager_id AND last_name != 'Higgins';
Oracle Database 10 g : SQL Fundamentals II 7 - Summary You can use hierarchical queries to retrieve data based on a natural hierarchical relationship between rows in a table. The LEVEL pseudocolumn counts how far down a hierarchical tree you have traveled. You can specify the direction of the query using the CONNECT BY PRIOR clause. You can specify the starting point using the START WITH clause. You can use the WHERE and CONNECT BY clauses to prune the tree branches.
Oracle Database 10 g : SQL Fundamentals II 7 - Practice 7: Overview In this practice, you gain practical experience in producing hierarchical reports. Note: Question 1 is a paper-based question.
Oracle Database 10 g : SQL Fundamentals II 7 - Practice 7 1. Look at the following output examples. Are they the result of a hierarchical query? Explain why or why not. Exhibit 1: Exhibit 2: …
Oracle Database 10 g : SQL Fundamentals II 7 - Practice 7 (continued) Exhibit 3: 2. Produce a report showing an organization chart for Mourgos’s department. Print last names, salaries, and department IDs. 3. Create a report that shows the hierarchy of the managers for the employee Lorentz. Display his immediate manager first.
Oracle Database 10 g : SQL Fundamentals II 7 - Practice 7 (continued) 4. Create an indented report showing the management hierarchy starting from the employee whose LAST_NAME is Kochhar. Print the employee’s last name, manager ID, and department ID. Give alias names to the columns as shown in the sample output. If you have time, complete the following exercise: 5. Produce a company organization chart that shows the management hierarchy. Start with the person at the top level, exclude all people with a job ID of IT_PROG , and exclude De Haan and those employees who report to De Haan. …