How do I escape a reserved word in Oracle?(如何在 Oracle 中转义保留字?)
问题描述
在 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 中转义保留字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Oracle 中转义保留字?
基础教程推荐
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
