‘ORA-00904: "AGE": invalid identifier’ The association between double quote and case sensitivity

异常原因

造成‘ORA-00904: "AGE": invalid identifier’ 的根本原因是数据库不能识别你所给出的列。可能是列名写错了,大小写敏感。以下主要讲解如何解决由大小写敏感造成的这个问题。

A solution from Stack overflow:

Oracle SQL allows us to ignore the case of database object names provided we either create them with names all in upper case, or without using double quotes. If we use mixed case or lower case in the script and wrapped the identifiers in double quotes we are condemned to using double quotes and the precise case whenever we refer to the object or its attributes.

大意阐述:

1.当我们使用全大写加引号或者不在列上使用双引号时创建表的时候,数据库是大小写不敏感的。

全大写加引号:

 create table allupper(
   "NAME" varchar2(8),
   "AGE" number);

select name,AGE from allupper;

结果:查询可通过。


不在列上使用双引号:

 create table noquote(
   name varchar2(8),
   age number);

 select name,AGE from noquote;

结果:查询可通过。

2.如果使用了“”而且列名包含大小写, 那么你必须使用和创建表时一模一样的列名,并且加上“”。

使用了双引号,并且还有大小写

create table mixcase(
  "NAme" varchar2(8),
   "Age" number);

 select name,AGE from mixcase;

结果:查询不可通过。ORA-00904: "AGE": invalid identifier

select "NAme","Age" from mixcase;

结果:查询可通过。

TIP:

一般我们很少通过表名称的大小写敏感来区分两个表,所以我们应该在创建表的时候尽量不要使用引号。这样就可以做到表名称大小写不敏感。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值