码迷,mamicode.com
首页 > 其他好文 > 详细

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

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

标签:5.7   sel   ati   group by   href   tar   cas   class   ash   

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:

标签:5.7   sel   ati   group by   href   tar   cas   class   ash   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!