Last Updated: February 25, 2016
·
1.213K
· Andrew Stilliard

MySQL: Select all indexes from all tables in a given MySQL databbase

In this example its called my_db

SELECT table_name, index_name, GROUP_CONCAT(DISTINCT column_name), index_type
FROM information_schema.statistics
WHERE table_schema = 'my_db'
AND non_unique = 1
GROUP BY table_name, index_name, index_type ;

gist available too for links or forks: https://gist.github.com/stilliard/b0aaeac65468c5193806


This protip is part of a series on information_schema.

A treasure trove of useful information, such as:

SELECT *
FROM information_schema.statistics
WHERE table_schema = 'my_db' ;