码迷,mamicode.com
首页 > 数据库 > 详细

将数据库中所有的表的列导入到指定文件的脚本

时间:2019-10-14 12:49:22      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:ati   column   指定   表名   文件中   微软   微软雅黑   一个   数据   

#!/bin/bash

tables=`cat /tmp/test/tables`

for TABLE in $tables

do

echo "$TABLE" >> /tmp/test/txt/1.txt

mysql -uroot -p‘Admin123,.‘ -e "SELECT column_name FROM information_schema.columns WHERE table_schema=‘zwfw‘ AND table_name=‘$TABLE‘" >> /tmp/test/txt/1.txt

done

? ?

需要预先将所有的表名写入到tables文件中,一行一个,zwfw为被查询的数据库

? ?

将数据库包含的表的名字导入到tables文件的命令为

mysql -uroot -p‘Admin123,.‘ -e "SELECT table_name FROM information_schema.tables WHERE table_schema=‘zwfw‘ AND table_type=‘base table‘" >> /tmp/test/tables

? ?

zwfw为要查询的数据库,tables为指定的文件

? ?

将数据库中所有的表的列导入到指定文件的脚本

标签:ati   column   指定   表名   文件中   微软   微软雅黑   一个   数据   

原文地址:https://www.cnblogs.com/withfeel/p/11670641.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!