#!/bin/sh
tables=`mysql -u root -e "use i_test;show tables;"`
for list in $tables
do
if [ $list == 'Tables_in_i_test' ];
then
echo "Table in i_test:" >> a.txt
else
echo >>a.txt
echo TABLE "["$list"]" DESCRIBE:>>a.txt
mysql -u root -t -e"desc i_test.$list" |tee -a a.txt
fi
done
本文介绍了一个用于从MySQL数据库中导出指定数据库的所有表结构及其描述信息的Shell脚本。该脚本通过遍历所有表并利用MySQL命令行工具收集表信息,最终将这些信息汇总到一个文本文件中。对于需要快速获取数据库表结构和字段信息的场景非常实用。
227

被折叠的 条评论
为什么被折叠?



