Skip to content

Instantly share code, notes, and snippets.

@smerrill
Created June 13, 2010 19:10
Show Gist options
  • Save smerrill/436905 to your computer and use it in GitHub Desktop.
Save smerrill/436905 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Variables definitions
DBNAME="tony_local_test"
MYSQL_COMMON="-uroot -D$DBNAME"
SQL_QUERY="SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '$DBNAME' AND ENGINE='MyISAM';"
ALTER_TABLE_QUERY=""
# Build up one giant SQL string.
for i in `mysql $MYSQL_COMMON --skip-column-names -s -e "$SQL_QUERY"`; do
ALTER_TABLE_QUERY=$ALTER_TABLE_QUERY"ALTER TABLE $i ENGINE=InnoDB;"
done
# Execute that long-ass query.
mysql $MYSQL_COMMON -e "$ALTER_TABLE_QUERY";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment