经过再sqlplus 中使用 new_value,能够把从表中查询出来的值,放置到 变量中。
而后使用变量时,相似与宏定义同样,就能够像使用表中字段同样方便。
这使得sqlplus 的脚本具有和pl/sql 相似的能力,方便监控和诊断程序的编写。
下面是一个小例子,经过 new_value ,使得 查询出来的 opt_mode_val 的内容,直接赋予给了 my_opt_mode_val。sql
col opt_mode_val new_value my_opt_mode_val noprintselect value opt_mode_valfrom v$parameterwhere name = 'optimizer_mode';SQL> select 'The current optimizer mode is '||'&&my_opt_mode_val' from dual;old 1: select 'The current optimizer mode is '||'&&my_opt_mode_val' from dualnew 1: select 'The current optimizer mode is '||'ALL_ROWS' from dual'THECURRENTOPTIMIZERMODEIS'||'ALL_ROWS--------------------------------------The current optimizer mode is ALL_ROWSSQL>