Column Name beginning with a number? Column Name beginning with a number? sql sql

Column Name beginning with a number?


If you are using column names that start with a number then you need to use double quotes. For example:

create table foo ("3RD_DIAG_CODE" varchar2(10 byte) --make sure you use uppercase for variable name);insert into foo values ('abc');insert into foo values ('def');insert into foo values ('ghi');insert into foo values ('jkl');insert into foo values ('mno');commit;select * from foo;3RD_DIAG_C----------abcdefghijklmnoselect 3RD_DIAG_CODE from foo;RD_DIAG_CODE------------       3       3       3       3       3select "3RD_DIAG_CODE" from foo;3RD_DIAG_C----------abcdefghijklmno

Edit: As for the error message itself, you are probably (as BQ wrote) missing a comma from the select clause.


Check your specification, but in SQL Server we would have to enclose that column name in square brackets: [3RD_DIAG_CODE]


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:39Error report:SQL Error: ORA-00904: : invalid identifier00904. 00000 -  "%s: invalid identifier"create table t (id number primary key, "3d" varchar2(30));table T created.desc tName 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 tID                     3d                             ---------------------- ------------------------------ > select id, [3d] from tError starting at line 7 in command:select id, [3d] from tError at Command Line:7 Column:11Error report:SQL Error: ORA-00936: missing expression00936. 00000 -  "missing expression"*Cause:    *Action:> select id 3d from tError starting at line 8 in command:select id 3d from tError at Command Line:8 Column:10Error report:SQL Error: ORA-00923: FROM keyword not found where expected00923. 00000 -  "FROM keyword not found where expected"*Cause:    *Action: