Getting info on Indices using ODBC

Just starting out? Need help? Post your questions and find answers here.
Duffer123
User
User
Posts: 42
Joined: Fri Nov 30, 2012 11:40 pm

Getting info on Indices using ODBC

Post by Duffer123 »

Hi,

Can anyone post any code about how I would interrogate a database in ODBC to gather details of indices per table or for a particular table in the ODBC database??

Just can't fathom it...
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Getting info on Indices using ODBC

Post by infratec »

Hi,

this has nothing to do with ODBC it has to do with the database behind.
Without knowledge of the database behind no one can tell you the SQL syntax for getting these
informations.

Bernd
Iron Saint
New User
New User
Posts: 1
Joined: Sun Dec 28, 2014 12:21 am

Re: Getting info on Indices using ODBC

Post by Iron Saint »

Hello Duffer123,

You can execute a SELECT statement similar to SQLite's "select * from sqlite_master" on any database. The resultant data set will give you the information you're looking for.

For example, on Oracle you can use "SELECT * FROM user_indexes WHERE table_name = 'A_TABLE_NAME'" to retrieve the index metadata.

Note that other databases, such as DB2 or SQL Server, have slightly different ways of retrieving metadata so you will have to taylor your code specifically to that database.

Cheers,
IS
Post Reply