How do I convert / change / delete more then one MySQL table?

Daniel Urstöger
01-12-2008 13:37

Well, a quite simple task but still with a few dozen tables this might become quite some work in phpMyAdmin for example.

To solve this, we will use / write a simple bash script:

for t in $(mysql --batch --column-names=false -e "show tables" DBNAME);
do
mysql -e "alter table $t type=InnoDB" DBNAME;
done

That´s about it, you can replace the third line with other functions too, e.g.:
mysql -e "drop table $t" DBNAME
etc.
 
Enjoy! 
Average rating: 0 (0 Votes)

You cannot comment on this entry