Record - sqlplus used in connection Dsql under Linux oracle sql execution method

oracle sql 1 written to be performed

test.sql written to be performed in Oracle, the acquired data into the data.txt.

set line 4100
set pagesize 0
set feedback off
set heading off
set trimspool on
set trims on
set trimout on
set echo off
set colsep $$$
set termout off
spool data.txt
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
spool off
exit 

2 Write the script dsql

Dsql write scripts test.dsql, it will connect using sqlplus oracle execution test.dsql

.os rs0=`sqlplus dbName/user@10.0.0.0:0/passwd @test.sql ` 
.IF ERRORCODE <> 0 THEN .QUIT 12;

3 writing shell scripts and script execution dsql

Dsql -c $logon.file -f test.dsql >> $log 2>&1

$ Logon.file is login and password file

4 in the shell to view the captured data

cat data.txt
Released six original articles · won praise 1 · views 1844

Guess you like

Origin blog.csdn.net/weixin_42532747/article/details/104801520