diff --git a/HowtoMySQL.md b/HowtoMySQL.md index 35fcab7d..d7bb8b76 100644 --- a/HowtoMySQL.md +++ b/HowtoMySQL.md @@ -773,6 +773,35 @@ FROM information_schema.TABLES ORDER BY (data_length + index_length) DESC; ~~~ +Pour lister tous les Indexes de toutes les tables et de toutes les bases : + +~~~ +select index_schema, index_name, group_concat(column_name order by seq_in_index) as index_columns, index_type, case non_unique when 1 then 'Not Unique' else 'Unique' end as is_unique, table_name from information_schema.statistics where table_schema not in ('information_schema', 'mysql', 'performance_schema', 'sys') group by index_schema, index_name, index_type, non_unique, table_name order by index_schema, index_name; +~~~ + +En version plus "lisible" pour mettre dans un script ou autre : + +~~~ +select index_schema, + index_name, + group_concat(column_name order by seq_in_index) as index_columns, + index_type, + case non_unique + when 1 then 'Not Unique' + else 'Unique' + end as is_unique, + table_name +from information_schema.statistics +where table_schema not in ('information_schema', 'mysql', + 'performance_schema', 'sys') +group by index_schema, + index_name, + index_type, + non_unique, + table_name +order by index_schema, + index_name; +~~~ ## Logs