获取缺失主键表信息的MYSQL语句
程序员文章站
2024-02-20 17:56:52
复制代码 代码如下: select a.`table_schema` as db_name , a.`table_name` , a.`table_rows` ,a.`en...
复制代码 代码如下:
select a.`table_schema` as db_name , a.`table_name` , a.`table_rows` ,a.`engine` -- , a.*
from
information_schema.`tables` a
left join information_schema.`table_constraints` b
on a.`table_name` = b.`table_name` and a.`table_schema` = b.`table_schema`
where b.`table_schema` is null
and a.`table_type` = 'base table'
and a.`table_schema` not in ('information_schema','test','mysql','performance_schema')
order by db_name ,a.`table_rows` desc ;