INDEX IN ORACLE SQL

In Oracle SQL, an index is a database object that allows for fast retrieval of data by providing a quick access path to the data stored in a table. When a table is indexed, it creates a separate data structure that contains the indexed column's values and their corresponding rowids, which help to quickly locate and retrieve the relevant data.



Here is an example of creating an index on a column in a table:

CREATE INDEX idx_last_name

ON employees (last_name);


In this example, we are creating an index named idx_last_name on the last_name column in the employees table. This index will allow for faster retrieval of data based on the values stored in the last_name column.

To see the effect of the index, we can run a query that includes the indexed column:

SELECT employee_id, first_name, last_name
FROM employees
WHERE last_name = 'Ajay';

Assuming that the last_name column is heavily used in the employees table and has many rows, the query's execution time could be significantly faster with the use of the idx_last_name index.

Note that the specific results of this query will depend on the data stored in the employees table.

Post a Comment

Previous Post Next Post