+ Reply to Thread + Post New Thread
Results 1 to 4 of 4
  1. amy85's Avatar
    amy85 is offline Junior Member
    Join Date
    29 Jan 2009
    Posts
    11
    Say Thanks
    5
    Thanked 0 Times in 0 Posts

    ORA-00904: invalid identifier

    Hi another simple question ( sorry...)

    When I try to create a table like this , I get the error below
    Code :

     create table EMP (
            ID NUMBER not null,
            CREATION_DATE TIMESTAMP(3) not null,
            COMMENT VARCHAR2(255),
            primary key (ID)
        )

    Error:
    [B]ORA-00904:: invalid identifier[/B]
    SQL State: 42000
    Error Code: 904
    What am I missing?

    Thanks again (... and again)

  2.    Club-Oracle Complementary E-Books and Magazines
    Get your free Complementary Copy of Oracle Magazine

    You can also browse the Free Magazines and E-Books section to see the complete list of free magazines, e-books and Whitepapers.

  3. tyro's Avatar
    tyro is offline Forum Genius
    Join Date
    20 Aug 2008
    Location
    India
    Posts
    363
    Say Thanks
    0
    Thanked 17 Times in 17 Posts

    Re: ORA-00904: invalid identifier

    hey don't say sorry dear

    you can't use COMMENT as your column name (the invalid identifier) because it is a oracle reserved term.
    Use this
    Code :
    create table EMP (
            ID NUMBER not null,
            CREATION_DATE TIMESTAMP(3) not null,
            P_COMMENT VARCHAR2(255),
            primary key (ID)
        )

    But if you must use COMMENT as a column name put it in between double quotes as below:
    Code :
    create table EMP (
            ID NUMBER not null,
            CREATION_DATE TIMESTAMP(3) not null,
            "COMMENT" VARCHAR2(255),
            primary key (ID)
        )

    Cheers
    []

  4. The Following User Says Thank You to tyro For This Useful Post:

    amy85 (04-08-2009)

  5. rajavu's Avatar
    rajavu is offline Forum Genius
    Join Date
    13 Oct 2008
    Location
    @ Bangalore , India
    Posts
    410
    Say Thanks
    0
    Thanked 16 Times in 15 Posts

    Re: ORA-00904: invalid identifier

    As you might be knowing , it is not desirable to use the reserved words as a column name of a table . You have to use double quotes always in the application to refer the reserved key word column name. It is recommended to change the column name as suggested by Tyro.

    Code sql:
    SQL> CREATE TABLE EMP12 (
      2          ID NUMBER NOT NULL,
      3          CREATION_DATE TIMESTAMP(3) NOT NULL,
      4          "COMMENT" VARCHAR2(255),
      5          PRIMARY KEY (ID)
      6      )
      7  ;

    TABLE created.

    SQL> INSERT INTO  EMP12 VALUES ( 10, SYSTIMESTAMP, '1D=10');

    1 row created.

    SQL> SELECT ID ,COMMENT  FROM EMP12 ;
    SELECT ID ,COMMENT  FROM EMP12
               *
    ERROR at line 1:
    ORA-00936: missing expression


    SQL> SELECT ID ,"COMMENT"  FROM EMP12;

            ID COMMENT
    ---------- --------------------
            10 1D=10

    SQL>

    Raj.

  6. The Following User Says Thank You to rajavu For This Useful Post:

    amy85 (04-08-2009)

  7. amy85's Avatar
    amy85 is offline Junior Member
    Join Date
    29 Jan 2009
    Posts
    11
    Say Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: ORA-00904: invalid identifier

    hi guys thank you for your responses. I had initially used the double-quotes but now i have dropped that table and re-created with a different column name.

Similar Threads

  1. Replies: 3
    Last Post: 03-03-2010, 10:27 AM
  2. Replies: 7
    Last Post: 03-30-2009, 04:22 PM

Tags for this Thread