sqlplus执行脚本文件时如何传参数
2011-11-01 21:55
447 查看
d:\test.sql脚本如下:
执行时这样传参数:sqlplus "scott/tiger@test" @d:\test.sql sysdate dual
注意:参数必须用&[1-9]表示,不然传不进去,会提示让手动输入参数
如果脚本中有重复用到相同的值,如果&1=&2:
d:\tes2.sql
执行时,就必须传2个参数:
小窍门: 这时用procedure就可以不用传多个相同的参数,则只用传1个参数:
d:\test3.sql
sqlplus "scott/tiger@test" @d:\test3.sql 10
select &1 from &2; exit;
执行时这样传参数:sqlplus "scott/tiger@test" @d:\test.sql sysdate dual
注意:参数必须用&[1-9]表示,不然传不进去,会提示让手动输入参数
C:\>sqlplus "scott/tiger@test" @d:\test.sql sysdate dual D:\>sqlplus "scott/tiger@test" @d:\test.sql sysdate dual SQL*Plus: Release 11.2.0.1.0 Production on 星期二 11月 1 21:59:00 2011 Copyright (c) 1982, 2010, Oracle. All rights reserved. 连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 原值 1: select &1 from &2 新值 1: select sysdate from dual SYSDATE -------------- 01-11月-11 从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 断 开 D:\>
如果脚本中有重复用到相同的值,如果&1=&2:
d:\tes2.sql
delete scott.emp where no=&1 or deptno=&2; commit;
执行时,就必须传2个参数:
sqlplus "scott/tiger@test" @d:\test2.sql 10 10
小窍门: 这时用procedure就可以不用传多个相同的参数,则只用传1个参数:
d:\test3.sql
declare var_no number:=&1; begin delete scott.emp where no=var_no or deptno=var_no; commit; end;
sqlplus "scott/tiger@test" @d:\test3.sql 10
相关文章推荐
- sqlplus执行脚本文件时如何传参数
- linux上执行php脚本文件总是无故中断(如何让脚本后台执行不中断)
- Oracle 在Sqlplus 执行sql脚本文件。
- [MapReduce] 如何向map和reduce脚本传递参数,加载文件和目录
- Python脚本如何生成Windows可执行文件.exe
- 【hadoop】如何向map和reduce脚本传递参数,加载文件和目录
- 如何执行一个mysql的sql脚本文件
- Python脚本如何生成Windows可执行文件.exe
- MySql下如何执行sql脚本文件
- 获取隐含参数, 当前trace文件名称,sql语句的执行计划的脚本
- centos shell编程4【分发系统】 服务器标准化 mkpasswd 生成密码的工具 expect讲解 expect传递参数 expect自动同步文件 expect指定host和要同步的文件 expect文件分发系统 expect自动发送密钥脚本 Linux脚本执行方式 第三十八节课
- 如何执行一个mysql的sql脚本文件
- Android应用层如何执行脚本文件
- MySql下如何执行sql脚本文件
- (转自http://www.eact.com.cn/blog/html/30/5230-64253.html)【软件应用】如何执行vbs脚本文件
- IIS7 如何设置读取、脚本和可执行文件的执行权限
- [MapReduce] 如何向map和reduce脚本传递参数,加载文件和目录
- 如何在VS里的部署中执行一段 .sql 的脚本文件?
- MySql下如何执行sql脚本文件
- Python脚本如何生成Windows可执行文件.exe