Skip to content

Instantly share code, notes, and snippets.

@Caffe1neAdd1ct
Created November 28, 2019 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Caffe1neAdd1ct/3596261c4d7386501a9333baa66816bf to your computer and use it in GitHub Desktop.
Save Caffe1neAdd1ct/3596261c4d7386501a9333baa66816bf to your computer and use it in GitHub Desktop.
Find all indexes in a database to compare environments
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 in ('_DATABASE_NAME_')
group by index_schema,
index_name,
index_type,
non_unique,
table_name
order by index_schema,
index_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment