Column Name beginning with a number?

后端 未结 3 1129
名媛妹妹
名媛妹妹 2020-12-31 17:20

I have a column name in one of my tables called: 3RD_DIAG_CODE - VARCHAR2 (10 Byte)

When I try to run a query, it gives me the following error highlight

3条回答
  •  悲&欢浪女
    2020-12-31 18:13

    You probably have two columns listed without a comma between them.

    create table t (id number primary key, 3d varchar2(30))
    Error at Command Line:1 Column:39
    Error report:
    SQL Error: ORA-00904: : invalid identifier
    00904. 00000 -  "%s: invalid identifier"
    
    
    create table t (id number primary key, "3d" varchar2(30));
    table T created.
    desc t
    Name Null     Type         
    ---- -------- ------------ 
    ID   NOT NULL NUMBER       
    3d            VARCHAR2(30) 
    
    
    > select id, 3d from t --[as @gsiem mentions: THIS IS BAD]
    ID                     3D       
    ---------------------- -------- 
    
    > select id, "3d" from t
    ID                     3d                             
    ---------------------- ------------------------------ 
    
    > select id, [3d] from t
    
    Error starting at line 7 in command:
    select id, [3d] from t
    Error at Command Line:7 Column:11
    Error report:
    SQL Error: ORA-00936: missing expression
    00936. 00000 -  "missing expression"
    *Cause:    
    *Action:
    > select id 3d from t
    
    Error starting at line 8 in command:
    select id 3d from t
    Error at Command Line:8 Column:10
    Error report:
    SQL Error: ORA-00923: FROM keyword not found where expected
    00923. 00000 -  "FROM keyword not found where expected"
    *Cause:    
    *Action:
    

提交回复
热议问题