How can I dump each table in database in separate file with that table name?
+1
A:
You may want to check out the shell script suggested in the following article:
- How do I dump all tables in a database into separate files? by Sunny Walia
Script:
#!/bin/bash
db=$1
if [ "$db" = "" ]; then
echo "Usage: $0 db_name"
exit 1
fi
mkdir $$
cd $$
clear
for table in `mysql $db -e 'show tables' | egrep -v 'Tables_in_' `; do
echo "Dumping $table"
mysqldump --opt -Q $db $table > $table.sql
done
if [ "$table" = "" ]; then
echo "No tables found in db: $db"
fi
Daniel Vassallo
2010-06-22 05:47:44
thanks, working,,,
mabuzer
2010-06-22 06:11:09