Skip to content

Instantly share code, notes, and snippets.

@proxium
Last active August 29, 2015 14:25
Show Gist options
  • Save proxium/c322c043efb0a4a5568e to your computer and use it in GitHub Desktop.
Save proxium/c322c043efb0a4a5568e to your computer and use it in GitHub Desktop.
Shell command to do the drop (of all tables) in one shot
# Drop all tables from YOUR_DBSCHEMA_NAME
mysql --user=YOUR_USERNAME --password=YOUR_PASSWORD -BNe "show tables" YOUR_DBSCHEMA_NAME | tr '\n' ',' | sed -e 's/,$//' | awk '{print "SET FOREIGN_KEY_CHECKS = 0;DROP TABLE IF EXISTS " $1 ";SET FOREIGN_KEY_CHECKS = 1;"}' | mysql --user=YOUR_USERNAME --password=YOUR_PASSWORD YOUR_DBSCHEMA_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment