| Return To Topics |
Originally Posted: 6/10/2006 9:47:09 PM |
| |
Last Updated: 6/10/2006 9:47:09 PM |
Subject:
Composite Indexes and column orders
You Asked....
Say for instance I have a table called 'Employees' and I create a composite index on LastName and FirstName.
I know that a SQL statement will use the index when querying by LastName and LastName, FirstName
But what about when querying by FirstName alone or FirstName, LastName
and we responded....
Actually any variation of FirstName and LastName will utilize the Index.
This confused me also when I first started with SQL programming.
I came from an AS/400 -- RPG world and whenever querying a table via RPG you always needed to have an index in the exact order of the query. So for example, if you wanted to look by FirstName/LastName and LastName/FirstName you would need two indexes.
Not true in the SQL world
Review By: Posted From IP Address: 69.229.110.12
Are there any differences while using Oracle or SQL server or the rule holds true for both of them?
Thanks!
>>>>>Begin Original Message<<<<<
Say for instance I have a table called 'Employees' and I create a composite index on LastName and FirstName.
I know that a SQL statement will use the index when querying by LastName and LastName, FirstName
But what about when querying by FirstName alone or FirstName, LastName
>>>>>End Original Message<<<<<
Review On: 6/14/2006 11:47:51 AM
|