Oracle 报错 ORA-00904: 标识符无效
一般情况
一般情况下, 标识符错误是因为: 语句中的列名在表中不存在, 修改 sql 语句或者修改列名即可.
特殊情况
一般情况下, 建表语句如下:
- create table student(
- id int,
- name varchar2(100)
- )
但是如果建表语句写成了:
- create table student(
- "id" int,
- "name" varchar2(100)
- )
若给列名加了双引号, 表的列名查看时仍然为: id,name. 但是, 若使用如下查询语句则会报错: ORA-00904: 标识符无效
select id,name from student;
使用如下语句则不会报错:
select 'id','name' from student;
个人建议, 还是删了重建表吧, 这样写太恶心了.
遇到同样的问题, 确实恶心, 补充一点 如果建表语句写成了:
- create table student(
- "id" int,
- "name" varchar2(100)
- )
查询语句应该是:
select "id","name" from student t where "name" = "xxx";
作为查询条件时必须是双引号, 单引号不报错但是查询结果为空.
来源: http://www.linuxidc.com/Linux/2019-05/158743.htm