EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login

Oracle B Tree Index

Home » Data Science » Data Science Tutorials » Oracle Tutorial » Oracle B Tree Index

Oracle B Tree Index

Introduction to Oracle B Tree Index

B-Tree is also called as bitmap indexes and it is function based. The function-based index can be created by the user that means it index includes columns or we can say that upper function or included expression. Basically B tree is a balanced tree and it is not a binary tree, once we created B tree index then database automatically maintained index. In this type of tree we need to maintain a balance tree so that every insert, update and delete operation we keep the index of B tree. In oracle by default oracle creates B tree index, in oracle database management B tree starts with only two nodes such as one for header and one for leaf.

Syntax

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

create index specified index name on specified table name (colm name1, colm name2, ……..colm N);

Explanation

In the above syntax we use create index statement to create new index, here specified index name means new index name that we need to create , on is the keyword to gives the reference to database table, specified table name means actual table name in database and last part of syntax contain column names from specified table

How does B Tree index work in Oracle?

B Tree index is a top down approach, the height of the tree is used as an index that should change when we perform different operations such as insert, update and delete. Basically index is maintained in sequence of key value and there is no any storage clause used with index. If there is no room in an index lead node for an additional key value then we need to go sequentially at that time leaf node is split into two sections that one for leaf and remaining node is inserted into the sequence.

The node address is called DBS or we can also call the database block address. Basically DBS files resides in physical location and that file contain the File# and Block#, where File# is used for physical database file and Block# is used for data that is in file. The lead node is connected to the next node in proper sequence and that gives the index in logical order, that logical index stored on the assigned disk. This allows oracle to scan and search in descending order.

In a unique lookup passes through the branch levels to the leaf node and finds the individual value and each key value ROWID, the ROWID is a unique id and it also has a physical location. In oracle scan operation pass through the branch levels to find the first value in a given range then it reads across the leaf nodes until the range is satisfied.

ROWID contains the following parameters as follows.

  1. Object#
  2. File# is used for physical database files.
  3. Block# data in blocks or we can say nodes.
  4. Row# it pointer within the specified table.

This is an important feature of oracle and it is helpful to find blocks or nodes in the oracle database in a very effective manner.

The following diagram shows the internal structure of the B Tree index.

Popular Course in this category
Sale
Oracle Training (14 Courses, 8+ Projects)14 Online Courses | 8 Hands-on Projects | 120+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (9,633 ratings)
Course Price

View Course

Related Courses
Oracle DBA Database Management System Training (2 Courses)All in One Financial Analyst Bundle- 250+ Courses, 40+ Projects

Oracle-B-Tree-Index-graph

B Tree Index Split

See insertion operation indexes are maintained in a sequential manner if there is no node in leaf node for a newly inserted row at that time leaf node or block are split into two leaf nodes for either insert or update operation. The half part of row one leaf node and remaining part of row put into new leaf node and top side of tree operation required extra transaction to archive this work for oracle RDBMS. Downsides of the tree split are not good for performance because of the physical I/O process.

Examples

Now let’s see the different examples of B Tree index as follows.

First, see how we can create indexes as follows.

create index emp_index on empp (emp_id, salary);

Explanation

In the above example, we created emp_index by using the create index statement as shown. The end output of the above query we illustrate by using the following snapshot.

Oracle B Tree Index example

We have already created table names as empp and now we implement Full Index Scan as follows.

select emp_id, emp_dept, salary from empp where salary > 10000 order by emp_dept, emp_id;

Explanation

In the above example we use select, where and order by clause to implement Full Index Scan.  Considering emp_id and salary are the composite keys in the index, oracle database performs a full scan of the index, it reads in sorted order. The end output of the above query we illustrate by using the following snapshot.

Oracle B Tree Index output 1

Fast Full Index Scan

select emp_dept, salary from empp;

Explanation

In the above example we try to implement a fast full index scan. In which databases access the record in the index itself without accessing the table and there is any particular order. The end output of the above query we illustrate by using the following snapshot.

Oracle B Tree Index output 2

Index Unique Scan

select * from empp where emp_id = 4;

Explanation

In the above example we implement Index Unique Scan it must have either 0 or 1 rowid associated with an index key. The end output of the above query we illustrate by using the following snapshot.

output 3

Now assume that the emp_id column is the primary and is indexed with the following entries.

output 4

Rules and regulation for B Tree Index

Now let’s see the rules and regulation for B Trees index as follows.

  1. All leaves of B Tree we will create at the same level of tree.
  2. In B Tree we determine the degree of the tree and it is denoted by using d.
  3. The value of the left node of B Tree is always less than the value of the right node that means we can sort all nodes in ascending order from left to right.
  4. We can calculate maximum child node by using following formula d -1
  5. In B Tree each node except root node must be contain minimum keys such as d/2-1
  6. The maximum number of child nodes is equal to the degree of the tree.

Conclusion

We hope from this article you have understood about the Oracle B Tree Index. From this article, we have learned the basic syntax of the B Tree Index and we also see different examples of the B Tree Index. From this article, we learned how and when we use Oracle B Tree Index.

Recommended Articles

This is a guide to Oracle B Tree Index. Here we discuss the basic syntax of the B Tree Index and we also see different examples. You may also have a look at the following articles to learn more –

  1. Oracle Tablespace
  2. Oracle Bitmap Index
  3. Oracle NVL()
  4. PIVOT in Oracle

All in One Data Science Bundle (360+ Courses, 50+ projects)

360+ Online Courses

50+ projects

1500+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Oracle Tutorial
  • Advanced
    • Timestamp to Date in Oracle
    • Oracle Describe Table
    • Oracle Clauses
    • Oracle Having Clause
    • Oracle FOREIGN Key
    • PIVOT in Oracle
    • Oracle Alter Table
    • Oracle Queries
    • Oracle Views
    • Oracle Window Functions
    • Oracle String Functions
    • Oracle Date Functions
    • Oracle Analytic Functions
    • Oracle Aggregate Functions
    • Select in Oracle
    • INSERT in Oracle
    • DISTINCT in Oracle
    • Function in Oracle
    • Oracle GROUP_CONCAT
    • Oracle INSTR()
    • Oracle CONVERT
    • Oracle LENGTH()
    • Oracle EXISTS
    • Oracle REPLACE()
    • Oracle MERGE
    • Oracle LEAD()
    • Oracle EXTRACT()
    • Oracle LISTAGG()
    • Oracle SYS_CONTEXT()
    • Oracle COALESCE
    • Oracle NVL()
    • Oracle SYSDATE()
    • Oracle?Date Format
    • Oracle SYS_GUID()
    • Oracle WILDCARDS
    • Oracle Synonyms
    • Oracle Subquery
    • BETWEEN in Oracle
    • FETCH in Oracle
    • Oracle Index
    • Oracle Function-based Index
    • Oracle UNIQUE Index
    • Oracle Bitmap Index
    • Oracle Column
    • Oracle Triggers
    • Oracle Procedures
    • Sample Database for Oracle
    • Oracle LIKE Operator
    • ORDER BY in Oracle
    • Oracle ORDER BY DESC
    • GROUP BY in Oracle
    • Oracle GROUP BY HAVING
    • Oracle Aliases
    • Table in Oracle
    • Oracle Temporary Table
    • Oracle? Table Partition
    • Oracle rename table
    • Oracle CTE
    • Cursor in Oracle
    • Oracle LOCK TABLE
    • Oracle Tablespace
    • Oracle CARDINALITY
    • Oracle REGEXP
    • Oracle REGEXP_REPLACE
    • Oracle to_date
    • JSON in Oracle
    • Oracle COMMIT
    • Oracle GRANT
    • Oracle MD5
    • Oracle ROLLBACK
    • Oracle Users
    • Oracle TIMESTAMP
    • IF THEN ELSE in Oracle
    • Oracle While Loop
    • Oracle Clone Database
    • Oracle Backup Database
    • Oracle? XML
    • Oracle XMLAGG
    • Oracle XMLTABLE
    • Oracle Performance Tuning
    • Oracle B Tree Index
    • Oracle fusion
    • Oracle ebs
    • Oracle GRC
    • Oracle Cloud
    • Oracle HCM Cloud
    • Oracle Integration Cloud
    • Oracle Jinitiator
    • Oracle pathfinder
    • Oracle VirtualBox
    • Oracle Weblogic Server
    • Oracle decode
    • Oracle Exadata
    • Oracle ZFS
    • Oracle? utilities
    • JDBC Driver for Oracle
    • Oracle? DBA Versions
    • Oracle DBA Salary
  • Basic
    • Oracle Marketing Cloud
    • What is Oracle?
    • Career in Oracle
    • How to Install Oracle
    • Oracle Versions
    • What Is Oracle Database
    • Oracle Data Warehousing
    • Oracle Warehouse Builder
    • Career In Oracle Database Administrator
    • Career In Oracle DBA
    • What is Oracle RAC
    • Oracle DBA
    • Oracle? Vanderbilt
    • What is RMAN Oracle
    • Oracle Database Administration
    • Oracle Operators
    • Oracle Constraints
    • Oracle number
    • Oracle Data Types
    • Oracle UNIQUE Constraint
    • Oracle Check Constraint
  • Joins
    • Joins in Oracle
    • Inner Join in Oracle
    • Oracle Cross Join
    • Left Join in Oracle
    • OUTER Join in Oracle
    • Oracle Full Outer Join
    • Natural Join in Oracle
    • Oracle Self Join
    • Oracle hash join
    • Oracle? Update with Join
  • Oracle SET Operators
    • UNION in Oracle
    • Oracle UNION ALL
    • INTERSECT in Oracle
    • MINUS in Oracle
  • Interview Questions
    • Oracle Interview Questions
    • Oracle Apps Interview Questions
    • Oracle Apps Technical Interview Questions
    • Oracle Database Interview Questions
    • Oracle Forms Interview Questions
    • Oracle PL/SQL Interview Questions
    • Oracle RAC Interview Questions
    • Oracle SOA Interview Questions

Related Courses

Oracle Course Training

Oracle DBA Certification Course

MongoDB Certification Training

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

Special Offer - Oracle Course Training Learn More