Created
December 30, 2014 12:46
-
-
Save adfinlay/89f1b3971be696eb774c to your computer and use it in GitHub Desktop.
Get all MySQL tables without primary or unique keys
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 t.table_schema,t.table_name,engine | |
FROM information_schema.tables t INNER JOIN information_schema .columns c | |
on t.table_schema=c.table_schema and t.table_name=c.table_name | |
GROUP BY t.table_schema,t.table_name | |
HAVING sum(if(column_key in ('PRI','UNI'), 1,0)) =0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment