有一个Oracle表命名为保留字,可能会出现哪些问题? [英] Got an Oracle Table Named as Reserved Word, Which problems may arise?

查看:403
本文介绍了有一个Oracle表命名为保留字,可能会出现哪些问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们刚刚收到一个系统外包,乍一看,我可以看到一些名称为CASE或FROM的表格和字段。它是一个Oracle 10g数据库,我们将从Java,Hibernate,C#,C ++中消费这些数据。



有什么特别的,我们应该注意吗? / p>

对于我在其他帖子中看到的内容,这是不推荐的,因为它会影响我们的代码的可读性,但是还有其他可能导致的主要或更严重的问题



谢谢!

解决方案

要转义Oracle中的保留字,您需要使用双引号将它们(在这种情况下,表名称)括起来。 IE:

  SELECT * 
FROMCASE

否则,您会得到一个ORA-00903:无效的表名称错误。 IIRC,Oracle将双引号内的文本视为区分大小写,所以如果使用示例查询创建表名时,仍然可以得到错误。



除我只能看到通常的问题,具有不良命名的实体/属性。


We just got a system outsourced and at first glance i can see some tables and fields with names as CASE or FROM. It is an Oracle 10g DB and we are going to be consuming those data from Java, Hibernate, C#, C++.

Is there something special we should be aware of?

For what i've seen in other posts this is not recommended because it will affect readability of our code, but is there any other, major or more serious problems this could cause?

Thanks!

解决方案

To escape reserved words in Oracle, you need to enclose them (in this case, the table name) in double quotes. IE:

SELECT *
  FROM "CASE"

Otherwise, you'll get an "ORA-00903: Invalid table name" error. IIRC, Oracle treats text inside of double quotes as case sensitive so you can still get the error if the table name was created in lowercase when using the example query.

Other than that, I can only see the usual issue with poorly named entities/attributes.

这篇关于有一个Oracle表命名为保留字,可能会出现哪些问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆