oracle 设置扫描关闭目的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9011616/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SET SCAN OFF purpose
提问by Pavan Kumar Yarlagadda
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
谁能解释一下 SET SCAN OFF 和 SET SCAN On 的目的是什么?我知道它的目的是禁用替换变量和参数。但我想要一个明确的解释
回答by Code Magician
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 SCAN
已过时,但它用于控制是否应该扫描替换参数/变量。OFF
会阻止扫描参数/变量。
SET DEFINE
replaces/extends the functionality and a good writeup is here: http://shaharear.blogspot.com/2009/01/set-define.html
SET DEFINE
替换/扩展功能,这里有一篇很好的文章:http://shaharear.blogspot.com/2009/01/set-define.html
From the website
从网站
set define on;
select '&hello' from dual;
If define is set to on and SQL*Plus finds the current substitution prefix, it asks for a string to be entered. In the following example, I entered: hasan
Enter value for hello: this string was entered
设置定义;
从双中选择“&hello”;
如果define 设置为on 并且SQL*Plus 找到当前的替换前缀,它会要求输入一个字符串。在下面的例子中,我输入了:hasan
输入 hello 的值:已输入此字符串
old 1: select '&hello' from dual
new 1: select 'this string was entered' from dual
This is equivalent to how the old SET SCAN
would work. Basically you're controlling whether or not to prompt for a substitution
这相当于旧的SET SCAN
工作方式。基本上你在控制是否提示替换
回答by Justin Cave
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.
在 SQL*Plus(以及支持 SQL*Plus 语法的其他各种工具)中,默认情况下,该工具会扫描 SQL 语句以寻找替代变量。这允许您创建 SQL*Plus 脚本,这些脚本将 SQL*Plus 中定义的变量用于各种报告任务。
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"
因为替换变量以与号 ('&') 开头并且不需要提前声明,但是,如果您尝试运行恰好包含与号的 SQL 语句,则会产生问题。例如,如果您的INSERT
语句恰好有一个包含与号的字符串文字,您不希望 SQL*Plus 预处理该语句。或者,如果我想选择字符串“foo & bar”
SQL> set scan off;
SQL> ed
Wrote file afiedt.buf
1* select 'foo & bar' from dual
SQL> /
'FOO&BAR'
---------
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*Plus 对语句进行预处理,则文本“& bar”将被解释为替换变量,并且系统会提示我在运行时输入要替换的文本
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
回答by sina hey
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
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
'FOOSOMEVALUE' --------------foo 一些值