-
-
Save tobiase/0eb4147f9aab143dd856 to your computer and use it in GitHub Desktop.
drop empty tables
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
#!/bin/sh | |
# path settings | |
MYSQL=`which mysql` | |
# mysql settings | |
DB="MYDB" | |
HOST="127.0.0.1" | |
USER="root" | |
PASS="root" | |
# backup file settings | |
OPTS="" | |
# get tables | |
for t in `$MYSQL --host=$HOST --user=$USER --password=$PASS $OPTS $DB -e'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_ROWS =0 AND TABLE_SCHEMA = "$DB"' | grep -v TABLE_NAME`; | |
do $MYSQL --host=$HOST --user=$USER --password=$PASS $OPTS $DB -e "DROP TABLE $t;"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment