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' ;
Written by Stilliard
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mysql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#