一、最简单的shell里调用sqlplus. $ vi test1.sh #!/bin/bash sqlplus -S /nolog > result.log <<EOF set heading off feedback off pagesize 0 verify off echo off conn u_test/iamwangnc select * from tab; exit EOF $ chmod +x test1.sh $ ./test1.sh 二、把sqlplus执行结果传递给shell方...
echo"set echo off;">>${operate_sql}echo"set pagesize 0;">>${operate_sql}echo"set linesize 150;">>${operate_sql}echo"select username from dba_users;">>${operate_sql}echo"exit">>${operate_sql} sqlplus-S / as sysdba < ${operate_sql} > ${operate_sql_result} 方法三:利用重定向 ...
一、最简单的shell里调用sqlplus. $ vi test1.sh #!/bin/bash sqlplus -S /nolog > result.log < set heading off feedback off pagesize 0 verify off echo off conn u_test/iamwangnc select * from tab; exit EOF $ chmod +x test1.sh $ ./test1.sh 二、把sqlplus执行结果传递给shell方法一 ...
1、sqlplus --help 2、-S Sets silent mode which suppresses the display of the SQL*Plus banner, prompts, and echoing of commands.3、 sqlplus /nolog The /NOLOG option starts SQL*Plus without connecting to a database.例如sqlplus /nolog SQL> conn scott/tigger 4、实例test.sh !
1.SQl语句中没有循环的语句。正确。但pl/sql有。2.这是shell 和 sqlplus 交互的问题。有多种实现。途径:1)可以在shell中处理sql,2)也可以在plsql中处理调用shell.1)只需写shell脚本即可。2)需要配extproc,虽然有效,比较麻烦。不建议。3.如果让sqlplus 在shell循环,要重复连接很多次,不建议...
My #1 Oracle DBA tool is sqlplus –I use it to automate DBA tasks directly on the Oracle Server from shell scripts. I often put the output of sqlplus -s in a shell variable and use it for further processing. I also wrap the sqlplus script output in a shell function and pipe it’s ...
data=`sqlplus -s $SOURCE_DB<<EOF set pagesize 0 heading off echo off termout off feedback off linesize 1200 colsep "," trimspool on trimout on #列之间用,号隔开,linesize很重要 $source_sql_page quit;EOF` #必须顶格写 #delete last char SOURCE_DATA=${old_data%?} #去除字符串最后一...
sqlplus shell导出脚本 创建tb_a.sql文件 select id,name from tb_a; 创建tb_b.sql文件 select id,name from tb_b; 创建tb_a.sh yest定义昨天的时间,yyyymmdd #!/bin/sh yest=`date +%D | awk -F/ '{s=$2-1}{printf"20%02d%02d%02d\n", $3,$1,s}'`...
然后编写sql脚本,然后利用sqlplus 用户名/密码@XXX @sql命令文件.sql就可以了。如果害怕两个@有冲突,那么就设置一个参数=用户名/密码@XXX 然后调用参数,就可以了。如果还有其他需求,那么就利用sqlplus的set参数,来达到某些目的。sqlplus的参数,比如-s等,也会有一些用处,这个要自己把握了。
exec_sql.sh。如前所述,只要用户有权访问 sqlplus,就可以从 shell 脚本中查询数据库。以下示例返回当前在数据库中保持会话状态的计算机列表(由空格分隔): #!/bin/bash output=‘sqlplus -s "/ as sysdba" <<EOF set heading off feedback off verify off ...