Tuesday 4 April 2017

indexing - How to see indexes for a database or table in MySQL?



How do I see if my database has any indexes on it?



How about for a specific table?


Answer



To see the index for a specific table use SHOW INDEX:



SHOW INDEX FROM yourtable;



To see indexes for all tables within a specific schema you can use the STATISTICS table from INFORMATION_SCHEMA:



SELECT DISTINCT
TABLE_NAME,
INDEX_NAME
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = 'your_schema';



Removing the where clause will show you all indexes in all schemas.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...