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: Arto Viitanen <arto.viitanen_at_csc.fi>
Date: Wed, 25 Jan 2006 08:54:07 +0200
Message-ID: <43d7208f$0$10074$ba624cd0@newsread.funet.fi>


Mark C. Stock wrote:
> "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
>
>

Yes, but funny thing was, why 1.foo gives floating point number, but 1."foo" gives integer. I tested this on MySQL and it gives 1 on both cases.

--
Arto Viitanen, CSC Ltd
Espoo, Finland
Received on Wed Jan 25 2006 - 00:54:07 CST

Original text of this message

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