Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: select constant.field

Re: select constant.field

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Tue, 24 Jan 2006 06:09:48 -0500
Message-ID: <uPqdnQjHA9KdlkvenZ2dnUVZ_tSdnZ2d@comcast.com>

"Arto Viitanen" <arto.viitanen_at_csc.fi> wrote in message news:43d60342$0$10073$ba624cd0_at_newsread.funet.fi...
> Why can I make following query
>
> select 1.foobar from dual
>
> Result is 1.0 (Oracle 10g1 EE, 32 bit Linux)
>
> So why can I use number as a table name (or actually table alias) and
> why that "table" can have what ever field?
>
> When I tried
>
> select 1."foo bar" from dual
>
> I get 1 as result.
>
> --
> Arto Viitanen, CSC Ltd
> Espoo, Finland

  1. is a valid expression . is evidently a valid token separator (ie. Oracle parser detects the end of a numeric expression and the beginning of a new text token -- this happens for 1xxxx as well)

so your query is the equivalent of

select 1. xxxx
from dual

which is the equivalent of

select 1. as xxxx
from dual

bottom line '1.' is a numeric expression -- the text (quoted or not) after the decimal is being interpreted as a column alias (which you'll notice if you take a close look at you output in SQL*Plus)

i.e.

SQL> select 1xxx from dual;

       XXX


         1

++ mcs Received on Tue Jan 24 2006 - 05:09:48 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US