如何将数据库中的每个表转储到具有该表名的单独文件中? 最佳答案 您可能想要查看以下文章中建议的
shell脚本:
> How do I dump all tables in a database into separate files? by Sunny Walia
脚本:
#!/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