首页 > 其他 > 详细

The query below helps you to locate tables without a primary key:

时间:2018-07-12 23:17:17      阅读:195      评论:0      收藏:0      [点我收藏+]

SELECT tables.table_schema, tables.table_name, tables.table_rows
FROM information_schema.tables
LEFT JOIN (
SELECT table_schema, table_name
FROM information_schema.statistics
GROUP BY table_schema, table_name, index_name
HAVING
SUM(
CASE WHEN non_unique = 0 AND nullable != ‘YES‘ THEN 1 ELSE 0 END
) = COUNT(*)
) puks
ON tables.table_schema = puks.table_schema AND tables.table_name = puks.table_name
WHERE puks.table_name IS NULL
AND tables.table_schema NOT IN (‘mysql‘, ‘information_schema‘, ‘performance_schema‘, ‘sys‘)
AND tables.table_type = ‘BASE TABLE‘ AND engine=‘InnoDB‘;

 

mysql> SET GLOBAL slave_rows_search_algorithms = ‘INDEX_SCAN,HASH_SCAN‘;

https://dev.mysql.com/doc/refman/5.7/en/replication-options-slave.html#option_mysqld_slave-rows-search-algorithms

The query below helps you to locate tables without a primary key:

原文:https://www.cnblogs.com/moss_tan_jun/p/9302285.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!