- spool spoolfile append
从10g开始sqlplus支持向已有spool file中追加内容
- SQLPATH环境变量
与操作系统的PATH环境变量类似,用于指定sql脚本的路径。在sqlplus中执行脚本时无需指定全路径。
例如:export SQLPATH=/app/oracle/scripts:/app/oracle/monitoring_scripts
- 编辑sql或pl/sql
刚执行过的sql或pl/sql会暂存在buffer中,可以通过以下方式编辑
SQL> define _editor=vi
SQL> edit
- &与&&的区别
&定义一个临时的替换变量,每次引用时会提示输入值
&&定义一个永久替换变量,第一次引用时会提示输入值,以后引用时不再提示,继续使用第一次输入的值。不需要时可在用undefine取消。
scott@ora10g: SQL> SELECT sal FROM emp WHERE ename LIKE '&NAME';
Enter value for name: SCOTT
old 1: SELECT sal FROM emp WHERE ename LIKE '&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'SAL
----------
3000scott@ora10g: SQL> /
Enter value for name: SCOTT
old 1: SELECT sal FROM emp WHERE ename LIKE '&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'SAL
----------
3000scott@ora10g: SQL> SELECT sal FROM emp WHERE ename LIKE '&&NAME';
Enter value for name: SCOTT
old 1: SELECT sal FROM emp WHERE ename LIKE '&&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'SAL
----------
3000scott@ora10g: SQL> /
old 1: SELECT sal FROM emp WHERE ename LIKE '&&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'SAL
----------
3000scott@ora10g: SQL> undefine NAME
scott@ora10g: SQL> l
1* SELECT sal FROM emp WHERE ename LIKE '&&NAME'
scott@ora10g: SQL> /
Enter value for name: SCOTT
old 1: SELECT sal FROM emp WHERE ename LIKE '&&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'SAL
----------
3000
- 清屏
SQL> clear screen