Junior — Middle
Can you name the main types of indexes used in databases?
sobes.tech AI
Answer from AI
Main types of indexes in databases:
- B-Tree index — the most common type, used for fast search, sorting, and range queries.
- Hash index — effective for exact key lookups but does not support range queries.
- Bitmap index — used for columns with a small number of unique values, well-suited for analytical queries.
- Full-text index — designed for text search, for example, in documents or articles.
Example of creating a B-Tree index in SQL:
CREATE INDEX idx_user_name ON users(name);
The choice of index type depends on the nature of the data and the types of queries to the database.