Oracle SQL 查询中的方括号是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11742580/
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
What means square brackets in Oracle SQL query?
提问by Ishikawa Yoshi
I find select statement with square brackets in it. Can anybody explain what does this brackets means?
我发现其中带有方括号的 select 语句。谁能解释一下这个括号是什么意思?
e.g.
例如
select a,b,[c] from table1;
Thanks.
谢谢。
采纳答案by Noah
According to oracle's documentation: http://docs.oracle.com/cd/B10500_01/text.920/a96518/cqspcl.htm
根据oracle的文档:http: //docs.oracle.com/cd/B10500_01/text.920/a96518/cqspcl.htm
The bracket characters serve to group terms and operators found between the characters; however, they prevent penetrations for the expansion operators (fuzzy, soundex, stem).
括号字符用于对字符之间的术语和运算符进行分组;但是,它们会阻止扩展运算符(fuzzy、soundex、stem)的渗透。
Its a grouping character in the query.
它是查询中的分组字符。
回答by DKroot
This is not a valid Oracle SQL nor PL/SQL.
这不是有效的 Oracle SQL,也不是 PL/SQL。
回答by Jon Heller
Square brackets in Oracle SQL are only used for cell referencing in the MODEL
clause. For example:
Oracle SQL 中的方括号仅用于MODEL
子句中的单元格引用。例如:
select *
from dual
model
dimension by (0 the_dimension)
measures (0 the_measure)
rules iterate(5)
(
the_measure[iteration_number] = iteration_number
);
THE_DIMENSION THE_MEASURE
------------- -----------
0 0
1 1
2 2
3 3
4 4
Other databases may use square brackets the way Oracle uses double quotation marks - to enable identifiers to use reserved words or other weird names. But a query like this is invalid in Oracle:
其他数据库可能像 Oracle 使用双引号一样使用方括号 - 使标识符能够使用保留字或其他奇怪的名称。但是这样的查询在 Oracle 中是无效的:
select a,b,[c] from table1;
There are many cases where square brackets in a string may have special meaning to some Oracle features. But characters inside a string don't normally count as part of a language's syntax or the grammar would never end. JSON, Text, regular expressions, and XML are some popular Oracle features that use square brackets in strings, but anybody could create their own custom sub-language.
在很多情况下,字符串中的方括号可能对某些 Oracle 功能具有特殊含义。但是字符串中的字符通常不算作语言语法的一部分,否则语法永远不会结束。JSON、文本、正则表达式和 XML 是一些流行的 Oracle 特性,它们在字符串中使用方括号,但任何人都可以创建自己的自定义子语言。
回答by Ramboslice
Square brackets in select statements are used when the table name contains a space for example
select语句中的方括号在表名包含空格时使用,例如
select * from [Department Managers]
Another time when [] are required is when a column or table name is the name of a built in SQL Server function or keyword for example, if a column is called from, this must be accessed like
Another time when [] are required is when a column or table name is the name of a built in SQL Server function or keyword for example, if a column is called from, this must be accessed like
Select [From],[To] from tbl
Good luck
Good luck