EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Oracle Tutorial Oracle B Tree Index
 

Oracle B Tree Index

Updated March 4, 2023

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.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax

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.

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

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

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

EDUCBA

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

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

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

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

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

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW