Ajout Pour lister tous les Indexes de toutes les tables et de toutes les bases

This commit is contained in:
emorino 2020-06-01 09:59:27 +02:00
parent 7c818da7c8
commit c4dbd91876

View file

@ -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