shell连接mysql、oracle
时间:2010-03-31 来源:huaihe0410
1.要求,自动登录mysql(root:root,passwd:123456),查询test库,test1表里的user=aa的记录.
#!/bin/sh
mysql -uroot -p123456 <<EOF
use test;
select * from testaa while a=10000; ###1000 not usr single quote mark,because a is int type,only char type need single quote mark.
EOF
2.拿oracle举个例子:
su - oracle -c sqlplus <<!
sys/sys as sysdba
spool /res.lst
selec * from test;
spool off
exit
!
#!/bin/sh
mysql -uroot -p123456 <<EOF
use test;
select * from testaa while a=10000; ###1000 not usr single quote mark,because a is int type,only char type need single quote mark.
EOF
2.拿oracle举个例子:
su - oracle -c sqlplus <<!
sys/sys as sysdba
spool /res.lst
selec * from test;
spool off
exit
!
相关阅读 更多 +