欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

获取缺失主键表信息的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 ;