REM Windows batch file to export metadata for one MySQL schema to XML REM using the mysql command line utility. REM REM Copyright (C) 2006 Roland Bouman REM R_P_Bouman@hotmail.com REM http://rpbouman.blogspot.com/ REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by REM the Free Software Foundation; either version 2 of the License, or REM (at your option) any later version. REM REM This program is distributed in the hope that it will be useful, REM but WITHOUT ANY WARRANTY; without even the implied warranty of REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the REM GNU General Public License for more details. REM REM You should have received a copy of the GNU General Public License REM along with this program; if not, write to the Free Software REM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA REM REM Usage: dump-information-schema localhost root mysqlroot sakila 3307 REM REM Arguments: REM 1: database host REM 2: username REM 3: password REM 4: schema REM 5: port REM mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.COLUMNS ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL;" > COLUMNS.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.COLUMN_PRIVILEGES WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.COLUMN_PRIVILEGES ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL;" > COLUMN_PRIVILEGES.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.EVENTS ON s.s = EVENT_SCHEMA WHERE EVENT_SCHEMA IS NULL" > EVENTS.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.FILES WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.FILES ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL" > FILES.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE CONSTRAINT_SCHEMA= schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.KEY_COLUMN_USAGE ON s.s = CONSTRAINT_SCHEMA WHERE CONSTRAINT_SCHEMA IS NULL;" > KEY_COLUMN_USAGE.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.PARTITIONS ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL" > PARTITIONS.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.ROUTINES ON s.s = ROUTINE_SCHEMA WHERE ROUTINE_SCHEMA IS NULL" > ROUTINES.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.SCHEMATA ON s.s = SCHEMA_NAME WHERE SCHEMA_NAME IS NULL" > SCHEMATA.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.SCHEMA_PRIVILEGES WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.SCHEMA_PRIVILEGES ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL" > SCHEMA_PRIVILEGES.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.STATISTICS ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL" > STATISTICS.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.TABLES ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL" > TABLES.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.TABLE_CONSTRAINTS ON s.s = CONSTRAINT_SCHEMA WHERE CONSTRAINT_SCHEMA IS NULL" > TABLE_CONSTRAINTS.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.TABLE_PRIVILEGES WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.TABLE_PRIVILEGES ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL" > TABLE_PRIVILEGES.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.TRIGGERS ON s.s = TRIGGER_SCHEMA WHERE TRIGGER_SCHEMA IS NULL" > TRIGGERS.xml mysql -h %1 -u %2 -p%3 -D %4 -P %5 -X -e"SELECT * FROM information_schema.VIEWS WHERE TABLE_SCHEMA = schema(); SELECT '' empty FROM (select schema() as s) s LEFT JOIN information_schema.VIEWS ON s.s = TABLE_SCHEMA WHERE TABLE_SCHEMA IS NULL" > VIEWS.xml