MySQL如何找出没有索引或主键的表
MySQL中如何找出没有主键的表或者没有索引的表呢?有时候,我们在管理、维护MySQL时,可能经常遇到这方面的需求,下面分享几个脚本,以便不时之需。
如何找出没有索引的用户表,下面三个脚本基本上能满足你的各种需求了:
找出MySQL所有用户数据库中没有索引的表
/*-**************************************************************************************************<br>-- Script Name : find_without_index_tables.sql <br>-- Script Funtion : 找出MySQL所有用户数据库中没有索引的表<br>****************************************************************************************************/<br>SELECT t.table_schema<br> ,t.table_name<br> ,t.table_type<br> ,t.engine<br> ,t.table_rows<br> ,t.row_format<br> ,t.avg_row_length<br> ,t.create_time<br>FROM information_schema.tables t<br>LEFT JOIN information_schema.statistics s<br> ON t.table_schema = s.table_schema AND t.table_name = s.table_name<br>WHERE t.table_schema NOT IN ( 'mysql', 'information_schema', 'performance_schema', 'sys', 'ndbinfo') <br> AND s.index_name IS NULL;<br>