Sql-server – How the indexes are managed

indexoraclesql server

I am trying to understand how the indexes are managed for below common data types:
1- Numeric (Integer, Decimals)
2- String (Varchar, Char)
3- DateTime

I have few questions:

1- How the indexes are stored for different data types? For example if have Numeric data like (100, 101, 100, 900, 700) & string data like (AAA,BBB,CCC,AAA,ABC) how the numericcolumn & stringcolumn index will store this data on disk?

2- Is there any different between the retrieval of a Numeric & String indexes? For example if i try the SELECT statements on numericIndexed column & on sringIndexes columns how they are retrieved?

3- Is the indexes are stored different by SQL Server & Oracle? OR they use the same logic?

Best Answer

For SQL Server, an index entry is stored pretty much the same way as a normal record except for the row header. Also, index and record entries are never on the same page

Now, anything I add to this would be copy/paste of articles by cleverer folk than me, so I'll refer you to Paul Randal: Inside the Storage Engine: Anatomy of a record

Also, all indexes in SQL Server are B-Tree. Tables with clustered indexes in SQL Server are the same as Oracle Index Organised tables

As for a SELECT, you have to consider if an index is "covering" or not usually. This means the entire SELECT can be satisfied from the index only. Otherwise it may not be used or generate key lookups. For more, see