我尝试使用带有减号、点等符号的列名。Oracle SQL 解析器不包括它们。像这样:
select
a.ID as Article-Number, a.Name as Name
from
Articles a
where
(a.ID = '3264')
它不例外a.ID as 'Article-Number'
(说"FROM keyword not found where expected"
)。我可以在列名中有符号吗?
您可以使用双引号 ( "
) 来转义别名和列名:
select
a.ID as "Article-Number", a.Name as "Name"
from
Articles a
where
(a.ID = '3264')
我可以在列名中有符号吗?
我在这里使东西自动化,所以我所有的别名都会得到双引号。重要的是我知道如何在我的别名中使用任何字符串。
在 Oracle 中,您使用双引号 ( "
) 来转义模式的名称(包括列名)。
但是,如果您尝试使事情自动化,则应注意以下几条规则:
ORA-00972: identifier is too long
"
) 或\0
(aka nul) 字符有关详细信息,请参阅Oracle 的模式对象命名规则。
问题仅Article-Number
作为别名。别名name
非常好。
SQL> select e.ename as name from emp e where rownum = 1;
NAME
----------
SMITH
SQL> select e.ename as Article-Number from emp e where rownum = 1;
select e.ename as Article-Number from emp e where rownum = 1
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
SQL> select e.ename as "Article-Number" from emp e where rownum = 1;
Article-Nu
----------
SMITH
SQL>
因此,只有as alias to escapedouble-quotation
才需要标记。Article-Number
-
1.我猜使用括号[]
Select [Name@Symbol], [#Sharp!#Column] from Your table
在此之前,您需要按此名称创建
2.您可以使用同义词来使用2个或多个名称...
如果您在评论中需要这种方式,请说。
东大