Created
October 7, 2020 19:00
-
-
Save thejsj/b6c8e1cae58efc402c297ce6948e4b74 to your computer and use it in GitHub Desktop.
Find all mysql tables with no primary key. Used to migrate old databases into Digital Ocean managed MySQL.
This file contains 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 table_schema ,table_name FROM information_schema.columns | |
WHERE table_schema <> 'sys' AND table_schema <> 'information_schema' AND table_schema <> 'mysql' AND table_schema <> 'performance_schema' | |
GROUP BY table_schema ,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