¿Qué significa corchetes en la consulta Oracle SQL?

I find select statement with square brackets in it. Can anybody explain what does this brackets means?

p.ej

select a,b,[c] from table1;

Gracias.

preguntado el 31 de julio de 12 a las 15:07

At least post the statement so we can see as well please!! -

That is not a valid statement in Oracle. It would hurl ORA-00936: missing expression. -

The problem that i have code (i know that this is Oracle code or pl/sql) and suddenly i see this symbols like in example, i never use this symbols before when i wrote my own Oracle code. I try to execute query like this but you right it return ORA-00936: missing exspression. That's why i asked this question. -

Can you show some of the actual code that you found rather than dummy code that you know fails? Does the code work against an Oracle DB? -

sry, i can't publish any part of this code -

4 Respuestas

This is not a valid Oracle SQL nor PL/SQL.

contestado el 26 de mayo de 16 a las 22:05

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.

contestado el 26 de mayo de 16 a las 23:05

I highly doubt that this is a correct answer. Oracle Text query syntax is used in CONTAINS(column, query) > 0 or similar clauses only. - Dmitriy Korobskiy

Square brackets in Oracle SQL are only used for cell referencing in the MODEL cláusula. Por ejemplo:

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.

contestado el 27 de mayo de 16 a las 05:05

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

Buena suerte

Respondido 31 Jul 12, 15:07

The question is tagged with Oracle. not SQL-Server - ypercubeᵀᴹ

Not in Oracle; reserved words etc. are enclosed in double quotes. - alex poole

Finally, the answer I was looking for. "double quotes". Thanks Alex. - Ryan

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.