问题描述
在 TSQL 中,我可以使用类似 Select [table] from tablename
来选择名为table"的列.
In TSQL I could use something like Select [table] from tablename
to select a column named "table".
如何在 oracle 中为保留字执行此操作?
How do I do this for reserved words in oracle?
我试过方括号、双引号、单引号和反引号,它们不起作用...
I've tried square braces, double quotes, single quotes, and backquotes, they don't work...
作为进一步说明,我有一个专栏,有人将其命名为评论.由于这是一个保留字,oracle 正在尝试用它进行选择,因此在解析查询时失败.我试过从表名中选择评论",但没有用.我会检查情况然后回来.
As a further clarification, I have a column which someone named comment. As this is a reserved word oracle is chucking a wobbly trying to select with it, its failing when parsing the query. I've tried Select "comment" from tablename but it didn't work. I'll check case and come back.
推荐答案
从快速搜索来看,Oracle 似乎使用双引号 ("
,例如 "table"
)并且显然需要正确的大小写——然而,对于任何感兴趣的人,MySQL 默认使用反引号 (`),除非为了兼容性而设置为使用双引号.
From a quick search, Oracle appears to use double quotes ("
, eg "table"
) and apparently requires the correct case—whereas, for anyone interested, MySQL defaults to using backticks (`) except when set to use double quotes for compatibility.
这篇关于如何在 Oracle 中转义保留字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!