设置扫描关闭目的
谁能解释一下 SET SCAN OFF 和 SET SCAN ON 的目的是什么?我知道它的目的是禁用替换变量和参数,但我想要一个清晰的解释。
Can anyone please explain what is the purpose of SET SCAN OFF and SET SCAN ON? I know its purpose is to disable substitution variables and parameters, but I want a clear explanation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SET SCAN
已过时,但它用于控制是否应扫描替换参数/变量。OFF
将阻止扫描参数/变量。SET DEFINE
替换/扩展了功能,这里有一篇很好的文章:http://shaharear.blogspot.com/2009/01/set-define.html来自网站
这相当于旧的 SET SCAN 的工作方式。基本上你正在控制是否提示替换
SET SCAN
is obsolete but it was used to control whether or not it should scan for substitution params/variables.OFF
would prevent scanning for params/variables.SET DEFINE
replaces/extends the functionality and a good writeup is here: http://shaharear.blogspot.com/2009/01/set-define.htmlFrom the website
This is equivalent to how the old
SET SCAN
would work. Basically you're controlling whether or not to prompt for a substitution在 SQL*Plus(以及支持 SQL*Plus 语法的各种其他工具)中,默认情况下,该工具会扫描 SQL 语句以查找替换变量。这允许您创建 SQL*Plus 脚本,使用 SQL*Plus 中定义的变量来执行各种报告任务。
然而,由于替换变量以 & 符号 ('&') 开头,并且不需要提前声明,因此,如果您尝试运行恰好包含 & 符号的 SQL 语句,就会产生问题。例如,如果您的
INSERT
语句恰好包含包含 & 符号的字符串文字,则您不希望 SQL*Plus 预处理该语句。或者,如果我想选择字符串“foo & bar”,但是如果我允许 SQL*Plus 预处理该语句,则文本 '& bar' 被解释为替换变量,系统会提示我输入要在运行时替换的文本
In SQL*Plus (and various other tools that support SQL*Plus syntax), by default, the tool scans SQL statements looking for substitution variables. This allows you to create SQL*Plus scripts that use variables defined in SQL*Plus for various reporting tasks.
Because substitution variables begin with the ampersand ('&') and need not be declared in advance, however, that creates problems if you are trying to run a SQL statement that happens to include an ampersand. For example, if you've got an
INSERT
statement that happens to have a string literal that includes an ampersand, you don't want SQL*Plus to pre-process the statement. Or, if I want to select the string "foo & bar"If I allow SQL*Plus to pre-process the statement, however, the text '& bar' is interpreted as a substitution variable and I'm prompted to enter the text to substitute at runtime
SQL>在 SQL 上设置扫描> /输入栏值:某个旧值 1:选择 'foo & bar' from Dual new 1:从 Dual
'FOOSOMEVALUE' 中选择 'foo some value' --------------foo some value
SQL> set scan on SQL> /Enter value for bar: some value old 1: select 'foo & bar' from dual new 1: select 'foo some value' from dual
'FOOSOMEVALUE' --------------foo some value