How to see indexes for a database or table in MySQL?

Blankman picture Blankman · Mar 6, 2011 · Viewed 490.2k times · Source

How do I see if my database has any indexes on it?

How about for a specific table?

Answer

Mark Byers picture Mark Byers · Mar 6, 2011

To see the index for a specific table use SHOW INDEX:

SHOW INDEX FROM yourtable;

To see indexes for all tables within a specific schema you can use the STATISTICS table from INFORMATION_SCHEMA:

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

Removing the where clause will show you all indexes in all schemas.