ORA-00972:标识符太长

时间:2013-01-08 15:43:35

标签: sql oracle oracle11g alias

我有一个查询,我在visual studio的查询工具中执行,我收到以下错误。

ORA-00972:标识符太长。

现在我相信我知道oracle有30个字节的限制,但这是我试图执行的查询。

   select 
          "cef_tsroma.tsrido" as "truck", 
          "cef_tsroma.dosvlg" as "rideNumber",
          "cef_v_cw_shipment.shipmentNumber" as "shipmentNumber"
   from 
          "cef_tsroma" left outer join "cef_v_cw_shipment" on "rideNumber" = "shipmentNumber"
   where 
          "truck" = '104490'

不幸的是,我无法更改数据库结构本身,因为它由另一家对数据库规范化一无所知的公司管理,或者处于他们根本不能或不应该的情况下。我不知道。请注意“cef_v_cw_shipment”是一个视图。

truck ='104490'只是用于测试目的的示例整数。我尝试了各种解决方案,但正确的方法(或寻找正确的方法)似乎无法解决。

真诚的,我。

P.S。对不起,如果这是一个愚蠢的问题。

编辑:

select 
      "cef_tsroma"."tsrido" as "truck", 
      "cef_tsroma"."dosvlg" as "rideNumber",
      "cef_v_cw_shipment"."shipmentNumber" as "shipmentNumber"
from 
      "cef_tsroma" left outer join "cef_v_cw_shipment" on "rideNumber" = "shipmentNumber"
 where 
      "truck" = '104490'

“rideNumber”现在是一个无效的标识符,我很快就会回到这里。我想我的方法是错误的,但我不确定。想找出来。

EDIT2:

  select 
  ct.tsrido as "truck", 
  ct.dosvlg as "rideNumber",
  cs.shipmentNumber as "shipmentNumber"
  from  "cef_tsroma" ct
  left outer join "cef_v_cw_shipment" cs
  on "rideNumber" = "shipmentNumber"
  where  "truck" = '104490'

我现在使用这种语法,因为它比前一种更清晰,更容易理解。然而,我仍然遇到ORA-00904:“rideNumber”:无效的标识符(这可能会计入shippingNumber以及连接线。尝试计算出这个仍然存在,google返回命名提示:没有成功。仍在搜索。

Edit3:

    select
            ct.tsrido as truck, 
            ct.dosvlg as rideNumber,
            cs.shipmentNumber as shipment
    from
            "cef_tsroma" ct
    left outer join 
            "cef_v_cw_shipment" cs 
    on 
            ct.dosvlg = cs.shipmentNumber
    where  
            truck = '104490'

现在提出以下建议,这是当前的语法。它当前返回错误消息:

ERROR ORA-00904:“CS”。“SHIPMENTNUMBER”:无效标识符

对不起,我没有设计这个数据库> ):

Edit4 /溶液

这似乎很有效,奇怪的是。

    select ct."tsrido", ct."dosvlg", cs."shipmentNumber" as shipmentnumber
    from "cef_tsroma" ct 
    left outer join "cef_v_cw_shipment" cs 
    on ct."dosvlg" = cs."shipmentNumber" 
    where ct."tsrido" = '104956';

3 个答案:

答案 0 :(得分:2)

你用整数table.column包装双引号。

select 
          "cef_tsroma"."tsrido" as "truck", 
          "cef_tsroma"."dosvlg" as "rideNumber",
          "cef_v_cw_shipment"."shipmentNumber" as "shipmentNumber"
from 
          "cef_tsroma" left outer join "cef_v_cw_shipment" on "rideNumber" = "shipmentNumber"
where 
          "truck" = '104490'

答案 1 :(得分:2)

报价错了。 “cef_tsroma.tsrido”应为“cef_tsroma”。“tsrido”......

在edit2上:新名称(别名)在WHEREJOIN子句中不起作用。要使用示例,可​​以重命名表X的列DUAL,但必须使用WHERE子句中的旧名称进行寻址:

SELECT dummy AS "myNewName" FROM dual WHERE "myNewName" = 'X';
-- ORA-00904: "myNewName": invalid identifier

SELECT dummy AS "myNewName" FROM dual WHERE dummy = 'X';
-- X

在edit3上:您的表名和列名看起来像普通的Oracle名称,它们不区分大小写。所以你可以删除所有的双引号:

select ct.tsrido         as truck,
       ct.dosvlg         as ridenumber,
       cs.shipmentNumber as shipmentnumber
  from cef_tsroma              ct 
  left join cef_v_cw_shipment  cs on ct.dosvlg = cs.shipmentnumber
 where ct.truck = '104490';

更详细地解释:Oracle表和列名通常不区分大小写。 Oracle以大写形式存储它们,但您可以在查询中以小写,大写或任意组合使用它们。

如果用双引号括起表名或列名,则会突然改变。然后Oracle坚持要完全拼写。

因此,在您的情况下,表格/视图"cef_tsroma"不存在,但cef_tsromaCEF_TSROMA"CEF_TSROMA"确实存在...

答案 2 :(得分:1)

您是否尝试过在表格中使用别名:

 select ct.tsrido as truck, 
      ct.dosvlg as rideNumber,
      cs.shipmentNumber as shipmentNumber
 from  cef_tsroma ct
 left outer join cef_v_cw_shipment cs
    on ct.dosvlg = cs.shipmentNumber
  where ct.tsrido = '104490'