oracle用shell腳本連接數據庫進行操做

zabbix#vi /opt/script/conf/config.sh
NAME_PW='username/password'
export NAME_PW
zabbix#vi /opt/script/logger.shsql

#!/bin/bash
. /opt/script/conf/config.sh
export ORACLE_SID=oracle1 #數據庫實例名
export ORACLE_HOME=/oracle/procduct/9.2
su oracle -c "${ORACLE_HOME}/bin/sqlplus -S /nolog" <<EOF
SET FEEDBACK OFF;
SET ECHO OFF;
CONN $NAME_PW
insert into table_test(id,date.messages) values('$!',sysdate,'$2')#向表table_test中插入數據
commit;
exit
EOF數據庫

zabbix#sh /opt/script/logger.sh 1,test#向數據庫中寫入數據bash

相關文章
相關標籤/搜索