ORA-00904错误:无效的标识符

29 浏览
0 Comments

ORA-00904错误:无效的标识符

我已经在我的虚拟XP中安装了Oracle 10g,并使用以下代码创建了一个表:

create table reg1 (
  fname varchar2(30),
  lname varchar2(30),
  addr varchar2(30),
  mail varchar2(30),
  occu varchar2(30),
  uname varchar2(30),
  passwd varchar2(30)
);

表成功创建。但是当我尝试使用简单的查询语句检索值时,例如:

select fname, lname 
  from reg1 
 where uname="bbb";

我收到了以下错误信息:

ORA-00904: "bbb": invalid identifier

我无法理解我在这里做错了什么。

0
0 Comments

ORA 00904错误:无效标识符的出现原因和解决方法

在数据库查询中,有时候会遇到ORA 00904错误:无效标识符(ORA 00904 Error: Invalid Identifier)的问题,本文将介绍这个问题出现的原因以及解决方法。

出现这个错误的原因很可能是在查询语句中使用了无效的标识符。一个常见的例子是在查询语句中使用了单引号。下面是一个示例代码:

select fname,lname from reg1 where uname='bbb';

在这个示例中,查询语句中使用了单引号将字符串'bbb'括起来。这是一个正确的用法,因为在SQL语句中,字符串常常需要用引号括起来。然而,如果在查询语句中使用了错误的引号类型,就会出现ORA 00904错误。

为了解决这个问题,我们需要确保在查询语句中使用正确的引号类型。在Oracle数据库中,单引号是用来表示字符串的,而双引号是用来表示标识符的。因此,如果在查询语句中使用了双引号,就会导致ORA 00904错误。

例如,如果我们将上面的查询语句中的单引号改为双引号,就会出现ORA 00904错误:

select fname,lname from reg1 where uname="bbb";

要解决这个问题,我们只需要将双引号改为单引号即可:

select fname,lname from reg1 where uname='bbb';

通过以上的方法,我们可以避免ORA 00904错误的发生,确保查询语句中使用了正确的引号类型。这样就可以顺利执行查询操作,获取正确的查询结果。

0
0 Comments

都 use double quotes to identify cased object names. When you enclose an object name with double quotes, it becomes case-sensitive. For example, the table "test" is not the same as the table test.

In your query, you are trying to select the columns fname and lname from the table reg1 where the uname column is equal to 'bbb'. However, instead of using single quotes to enclose the string value 'bbb', you mistakenly used double quotes.

This causes Oracle to interpret 'bbb' as an object name and search for a column named "bbb" in the reg1 table. Since this column does not exist, Oracle throws the ORA 00904 Error: Invalid Identifier.

To resolve this issue, you need to replace the double quotes with single quotes to enclose string values. Here is the corrected query:

select fname, lname from reg1 where uname = 'bbb';

By using single quotes, Oracle will correctly interpret 'bbb' as a string value to be compared with the uname column in the reg1 table.

0