1.mysql脚本文件 t.sql insert into test.t values(@name,@age); exit 2.shell脚本文件 a.sh (为方便演示,与t.sql文件放在同一目录下) #!/bin/sh # fetch user parameters input by user read -p "please input name value : " name read -p "please input name age : " age ec
这个例子演示了如何在shell脚本中执行多个sql来操作数据库表. #! /bin/sh USER_HOME=/home/`whoami` . /etc/profile if [ -f ${USER_HOME}/.bash_profile ]; then . ${USER_HOME}/.bash_profile fi mysql -h -ujifei30 -pNapnUszJD -Dtpssprod <<EOF select table_name from information_schema
查询员工信息 -S:静默登录 [oracle@localhost shells]$ cat shell1.sh #!/bin/bash #查询员工信息 sqlplus -S /nolog <<EOF conn scott/scott set feedback off set linesize 300 set pagesize 100 col empno for 99999 col ename for a12 col mgr for 9999 col hiredate for a20 col c