Home > Blogroll, sql > select 1.x from t1

select 1.x from t1

January 11th, 2008

I made a funny typo today :-)
SQL> select * from t1;

X
0

SQL> select 1.x from t1;

X
1

Should not I get ORA-904 invalid identifier :? ?

Bookmark and Share

  1. January 11th, 2008 at 13:34 | #1

    No, for the same reason that

    select ‘a’x from dual

    would not fail.

    select 1.
    from dual;

    works - 1. is a valid literal.

    select ‘literal’name
    from dual

    is valid (whitespace is many times optional)… hence

    select 1.x from dual

    is.

    ops$tkyte%ORA10GR2> select*from dual;

    D
    -
    X

  2. January 11th, 2008 at 14:31 | #2

    of course, thanks for the explanation !

  3. Matthias Rogel
    January 14th, 2008 at 17:36 | #3

    So, what does
    SQL > select 1.dummy from “DUAL”"1″;
    select 1.dummy from “DUAL”"1″
    *
    ERROR at line 1:
    ORA-03001: unimplemented feature

    tells us ?

  4. Ed Rusu
    January 14th, 2008 at 22:39 | #4

    Can you guys explain why the following statement works?

    select SYSDATE@! from dual;

    SYSDATE@!
    ———
    14-JAN-08

    SQL> select SYSDATE@!-4 from dual;

    SYSDATE@!
    ———
    10-JAN-08

  5. January 15th, 2008 at 10:56 | #5

    @matthias
    Probably in Oracle 17, “DUAL”"1″ will be a table called DUAL”1, in Oracle 11 and before, it is not possible to have a double quote in a table name

    @ed
    No idea !

  6. Claudia Zeiler
    January 15th, 2008 at 19:13 | #6

    For what it’s worth

    SQL> select sysdate from dual;

    SYSDATE
    ———
    15-JAN-08

    SQL> select sysdate@ from dual;
    select sysdate@ from dual
    *
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected

    SQL> select sysdate@! from dual;

    SYSDATE@!
    ———
    15-JAN-08

    SQL> select sysdate@1 from dual;
    select sysdate@1 from dual
    *
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected

    And I don’t understand anything any more!

  7. January 16th, 2008 at 01:25 | #7

    Currently I don’t have a database at hand, so I can really test it, but regarding:

    select 1.dummy from “DUAL””1″;

    Counting that the use of double quotas is a standard thing while for instance looking into the syntax of a dumpfile, generated by “exp”. I would expect that “1″ is regarded as a database link alias or such. With SQL*Net V1 this was the place to use the connection descriptor starting with the protocol (t for tcpip, d for dec, n for names - if I remember correctly). Therefore maybe the ORA-03001: unimplemented feature.

    Laurent are you sure you can’t use double quotes in a table name? Didn’t we wander these paths before…?

  8. January 16th, 2008 at 16:03 | #8

    Another little oddity. If you’re setting event 10053 and run

    select sysdate@! from dual;

    All you get is an empty tracefile (on 10.2.0.3) — seems the optimizer is choking on it ?

    Perhaps the “!” character has a special meaning (other than executing commands in your shell on *nix systems) ?

    Stefan

  9. Ed Rusu
    January 16th, 2008 at 23:18 | #9

    Maybe we should have a separate discussion on sysdate@! thing ;)
    It was found when sysdate was used with db link.
    I.e. SQL> select sysdate from dual@db_link;
    produces the following SQL in remote database:
    SELECT SYSDATE@! FROM “DUAL” “A1″

    Ed

  10. January 17th, 2008 at 21:52 | #10

    Sure there is an entertaining (and time consuming) explanation for each and every oddity, but how many developers really write a query without whitespace? I’m not aware of any modern programming language where whitespace is not a fundamental part of the syntax. Ditto for identifiers in quotes. Those should be deprecated (although was there a case when anything has been deprecated in SQL?)

  11. January 17th, 2008 at 23:14 | #11

    Come on, Mikito Harakiri, wasting our time is not only a side effect but the *sense* of dealing with SQL, programming languages and all the rest, isn’t t ?

  12. January 18th, 2008 at 09:15 | #12

    I wrote about no space query before :

    select*from”EMP”where’SCOTT’=”ENAME”and”DEPTNO”=20;

    My opinion is still that spaces helps readability. Personaly I am quite greedy with spaces, so I would not write COS ( 0 ) but COS(0).

    About wasting your time, I am a big fan of solving math problems with SQL 8-)

  13. January 18th, 2008 at 09:33 | #13

    Laurent,

    thanks for that great link !

    Σωκράτης

  1. January 14th, 2008 at 06:45 | #1
  2. January 15th, 2008 at 13:47 | #2