Oracle SQL语法:带引号的标识符 [英] Oracle SQL Syntax: Quoted identifier

查看:81
本文介绍了Oracle SQL语法:带引号的标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了看起来像这样的SQL查询

I encountered SQL queries that looked like

select "hello"
from "foo"."bar"

我发现我们可以在Oracle中使用带引号和不带引号的标识符: 数据库对象名称和限定符

I found that we can have quoted and unquoted identifiers in Oracle: Database Object Names and Qualifiers

...带引号的标识符以双引号()开头和结尾.如果使用带引号的标识符命名架构对象,则每次引用该对象时都必须使用双引号...

我问数据库管理员,他们告诉我有一个名为 bar 而不是"bar"

I asked the DBAs and they told me that there is a table with name bar but not "bar"

那是为什么?

推荐答案

该表名为bar,而不是BAR"bar",但是由于它是小写字母,因此您只能引用它使用双引号:

The table is named bar and not BAR or "bar" but because it is in lowercase you can only reference it using double quotes:

select * from bar; -- will fail

select * from "bar"; -- will succeed

道德是:从不创建这样的表!

The moral is: never create tables like this!

这篇关于Oracle SQL语法:带引号的标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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