ORA-00904: invalid identifier

in Oracle Database; Hi another simple question ( sorry...) When I try to create a table like this , I get the error ...

+ Post Reply + Post New Topic
Results 1 to 4 of 4
  1. #1
    amy85's Avatar
    amy85 is offline Junior Member amy85 is on a distinguished road
    Join Date
    29 Jan 2009
    Posts
    11
    Document Uploads
    0

    Helpful? Yes No

    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. #2
    tyro's Avatar
    tyro is offline Forum Genius tyro is on a distinguished road
    Join Date
    20 Aug 2008
    Location
    India
    Posts
    362
    Document Uploads
    0

    Helpful? Yes No

    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. #3
    rajavu's Avatar
    rajavu is offline Forum Genius rajavu is on a distinguished road
    Join Date
    13 Oct 2008
    Location
    @ Bangalore , India
    Posts
    482
    Document Uploads
    0

    Helpful? Yes No

    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.

  5. #4
    amy85's Avatar
    amy85 is offline Junior Member amy85 is on a distinguished road
    Join Date
    29 Jan 2009
    Posts
    11
    Document Uploads
    0

    Helpful? Yes No

    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, 09:27 AM
  2. ORA-00904 and PLS-00364 issue reg
    By laxman in forum SQL PL/SQL
    Replies: 6
    Last Post: 02-24-2010, 08:08 AM
  3. ORA-12154: TNS:could not resolve the connect identifier specified
    By farida.deen in forum Installation - Windows
    Replies: 1
    Last Post: 01-30-2010, 11:06 AM
  4. ORA-00904: : Invalid Identifier
    By Cushgod in forum SQL PL/SQL
    Replies: 1
    Last Post: 11-20-2009, 07:13 PM
  5. Replies: 7
    Last Post: 03-30-2009, 03:22 PM