Created
October 20, 2015 02:50
-
-
Save cmerrick/63dfb45ddf9708e0010b to your computer and use it in GitHub Desktop.
Truncate all tables in a MySQL DB
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/bash | |
DB=$1 | |
mysql -Ne "SELECT TABLE_NAME FROM TABLES WHERE TABLE_SCHEMA='$1'" INFORMATION_SCHEMA | while read TABLE; do | |
mysql -Ne "TRUNCATE \`$TABLE\`" $DB | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment