Saturday, July 24, 2010

MySQL :: Using XML in MySQL 5.1 and 6.0

MySQL Administrator can back up and restore schemas with SQL scripts. Individual tables can be selected and deselevcted in both phases. However, this wouldn't easily cover a scenario where one wants to back up data, modify the table columns and then restore the data because the scipt drops the table and then recreates it. It is however possible to manually alter the script.

Found a much better way - use command line tool mysqldump. It is decribed at http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

Most important option is -t , without it, drop and create statements are inserted, but with it, only the insert statements are created. There is also an --xml statement to produce XML output. This can be directly read in groovy. MySQL 6.0 will provide a LOAD XML command (read MySQL :: Using XML in MySQL 5.1 and 6.0) but that version is currently only alpha. So for now, it appears simpler to not use --xml.