@命令与start命令类似,区别在于:@命令既可以在SQL*Plus会话中运行,也可以在操作系统命令提示符中运行,而start命令只能在SQL*Plus会话中运行。
例如 在E盘中有一个sql文件query2.sql内容:
select empno,ename,job
from emp
where empno >&1 ;
使用@命令:
C:\Users\lmh>sqlplus scott/tiger @e:/query2.sql
SQL*Plus: Release 11.1.0.7.0 - Production on 星期二 11月 16 19:00:25 2010
Copyright (c) 1982, 2008, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
输入 1 的值: 7899
原值 3: where empno >&1
新值 3: where empno >7899
EMPNO ENAME JOB
---------- ---------- ---------
7900 JAMES CLERK
7902 FORD ANALYST
或者可以直接在后面接上变量的值:
C:\Users\lmh>sqlplus scott/tiger @e:/query2.sql 7780
SQL*Plus: Release 11.1.0.7.0 - Production on 星期二 11月 16 19:05:16 2010
Copyright (c) 1982, 2008, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
原值 3: where empno >&1
新值 3: where empno >7780
EMPNO ENAME JOB
---------- ---------- ---------
7782 CLARK MANAGER
7788 SCOTT ANALYST
7839 KING PRESIDENT
7844 TURNER SALESMAN
7876 ADAMS CLERK
7900 JAMES CLERK
7902 FORD ANALYST
7934 MILLER CLERK
已选择8行。