问题
I find select statement with square brackets in it. Can anybody explain what does this brackets means?
e.g.
select a,b,[c] from table1;
Thanks.
回答1:
According to oracle's documentation: 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).
Its a grouping character in the query.
回答2:
This is not a valid Oracle SQL nor PL/SQL.
回答3:
Square brackets in Oracle SQL are only used for cell referencing in the MODEL clause. For example:
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:
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.
回答4:
Square brackets in select statements are used when the table name contains a space for example
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
Select [From],[To] from tbl
Good luck
来源:https://stackoverflow.com/questions/11742580/what-means-square-brackets-in-oracle-sql-query