且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

列名以数字开头?

更新时间:2023-11-26 18:17:04

如果您使用以数字开头的列名,则需要使用双引号.例如:

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
----------
abc
def
ghi
jkl
mno

select 3RD_DIAG_CODE from foo;

RD_DIAG_CODE
------------
       3
       3
       3
       3
       3

select "3RD_DIAG_CODE" from foo;

3RD_DIAG_C
----------
abc
def
ghi
jkl
mno

对于错误消息本身,您可能(如BQ所写)在select子句中缺少逗号.

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