shell脚本中执行sql的例子

这个例子演示了如何在shell脚本中执行多个sql来操作数据库表。

#! /bin/sh
USER_HOME=/home/`whoami`
. /etc/profile
if [ -f ${USER_HOME}/.bash_profile ];
then
        . ${USER_HOME}/.bash_profile
fi

mysql -h 20.1.4.89 -P 8911 -ujifei30 -pNapnUszJD -Dtpssprod <<EOF
select table_name from information_schema.tables
 where table_schema = 'TPSSPROD';
select now();
exit
EOF

 

posted @ 2018-11-29 16:16  聚沙成塔  阅读(662)  评论(0编辑  收藏  举报