Indexing is a database technique that improves the speed of data retrieval operations by creating a data structure that allows fast lookups of specific rows in a table.
Indexes work like the table of contents in a book, allowing the database to quickly find data instead of scanning entire tables.
There are different types of indexes:
- Primary Index: Automatically created on primary key columns.
- Unique Index: Ensures that all values in a column are unique.
- Composite Index: Created on multiple columns.
- Full-Text Index: Used for searching text data.
Example SQL Query (Creating an Index):
sqlCopyEditCREATE INDEX idx_customer_name ON Customers(customer_name);
Now, queries filtering by customer_name
will be faster.
Leave a Reply