获取缺失主键表信息的MYSQL语句

前端技术 2023/09/06 MYSQL
复制代码 代码如下:

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 ;

本文地址:https://www.stayed.cn/item/17321

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。