Page 1 of 1

Getting info on Indices using ODBC

Posted: Fri Dec 26, 2014 5:39 pm
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...

Re: Getting info on Indices using ODBC

Posted: Sat Dec 27, 2014 1:16 pm
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

Re: Getting info on Indices using ODBC

Posted: Sun Dec 28, 2014 12:40 am
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