时间:2021-07-01 10:21:17 帮助过:18人阅读
#!/bin/bash
db_name="cert"
mysql_user="root"
mysql_passwd="34567"
table_name=`mysql -u$mysql_user -p$mysql_passwd -e "select table_name from information_schema.tables where table_schema=‘$db_name‘ and table_type=‘base table‘;"|grep -v table_name`
for a in $table_name
do
echo -e "\n$a 表中的字段\n"
mysql -u$mysql_user -p$mysql_passwd -e "select * from $db_name.$a limit 1;"|sed -n "1p"|awk ‘{for(i=1;i<=NF;i++)print $i}‘
done
获取mysql所有表中的字段
标签:echo type rom for tab cert base bash from