Skip to main content

Command Palette

Search for a command to run...

๐Ÿš€ Using Indexes in Oracle SQL to Improve Query Performance

Updated
โ€ข2 min read
๐Ÿš€ Using Indexes in Oracle SQL to Improve Query Performance

As part of my continued learning with Oracle Autonomous Database, I explored how indexes can improve query performance in SQL. Indexes help databases retrieve data faster, especially when working with large datasets.

๐ŸŽฏ Objective

The goal of this activity was to:

  • Understand what indexes are

  • Learn how to create an index

  • Improve query performance

๐Ÿ’ป Step 1: Creating the Table

CREATE TABLE employees (
  emp_id NUMBER,
  emp_name VARCHAR2(50),
  department VARCHAR2(50),
  salary NUMBER
);

๐Ÿงช Step 2: Inserting Data

INSERT INTO employees VALUES (1, 'Ali', 'IT', 50000);
INSERT INTO employees VALUES (2, 'Ahmed', 'HR', 70000);
INSERT INTO employees VALUES (3, 'Sara', 'IT', 60000);
INSERT INTO employees VALUES (4, 'Zara', 'HR', 65000);

โšก Step 3: Creating an Index

CREATE INDEX idx_salary ON employees(salary);

This index helps speed up queries that filter by salary.

๐Ÿ” Step 4: Querying Data

SELECT * FROM employees WHERE salary > 60000;๐Ÿ’ก What I Learned
  • What indexes are and why they are useful

  • How to create an index in Oracle SQL

  • Improving query performance

๐Ÿš€ Conclusion

This activity helped me understand how indexes optimize database queries. Indexes are an essential concept in database performance tuning and are widely used in real-world applications.

6 views

More from this blog

๏ฟฝ

๐Ÿš€ Getting Started with Oracle Autonomous Database (Free Tier) โ€“ My First Hands-on Experience

15 posts