[Oracle]Sqlplus 中使用 new_value

經過再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>
相關文章
相關標籤/搜索