mathiasfk mathiasfk - 6 months ago 26
SQL Question

Select indexes for all tables

How can I get all indexes for all tables on my DB?
Something like

show index
, but such as I could execute for all tables on a given DB and, more important, that I could use as a subquery.

Please notice that I'm not interested on the primary key, but on another index.

Edit:
So the solution that I was looking for is (based on aarbor's answer):

SELECT DISTINCT
TABLE_NAME,
INDEX_NAME,
COLUMN_NAME
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = schema() and index_name <> 'PRIMARY';

Answer
SELECT DISTINCT
    TABLE_NAME,
    INDEX_NAME
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = 'your_schema';

Taken from: This Post