Created
August 11, 2015 09:48
-
-
Save GerBawn/5db9a5608d06dc3ab41f to your computer and use it in GitHub Desktop.
产生select语句用于数据预热
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT | |
CONCAT('SELECT ',ndxcollist,' FROM ',db,'.',tb, | |
' ORDER BY ',ndxcollist,';') SelectQueryToLoadCache | |
FROM | |
( | |
SELECT | |
engine,table_schema db,table_name tb, | |
index_name,GROUP_CONCAT(column_name ORDER BY seq_in_index) ndxcollist | |
FROM | |
( | |
SELECT | |
B.engine,A.table_schema,A.table_name, | |
A.index_name,A.column_name,A.seq_in_index | |
FROM | |
information_schema.statistics A INNER JOIN | |
( | |
SELECT engine,table_schema,table_name | |
FROM information_schema.tables WHERE | |
engine='InnoDB' | |
) B USING (table_schema,table_name) | |
WHERE B.table_schema NOT IN ('information_schema','mysql') | |
ORDER BY table_schema,table_name,index_name,seq_in_index | |
) A | |
GROUP BY table_schema,table_name,index_name | |
) AA | |
ORDER BY db,tb | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
真的绝,把数据库所有表的都select * from 表,查一次