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

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


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_NAMEFROM INFORMATION_SCHEMA.STATISTICSWHERE TABLE_SCHEMA = 'your_schema';

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


If you want to see all indexes across all databases all at once:

use information_schema;SELECT * FROM statistics;


SHOW INDEX FROM mytable FROM mydb;SHOW INDEX FROM mydb.mytable;

See documentation.