简体   繁体   English

列名带有数字前缀(例如3name)是否合法?

[英]Is it valid syntax to have a column name prefixed with a number, e.g., 3name?

查询的屏幕截图

While toiling on a report last friday, I noticed a column that returned "3" for every row even though the data in the table said otherwise. 在上周五撰写报告时,我注意到即使表中的数据另有说明,该列的每一行仍返回“ 3”。 After squinting very hard at my sql, I noticed a typo in my select list that was causing the problem. 在对SQL进行非常严格的斜视之后,我注意到选择列表中的一个错字导致了问题。

Why does the sql parser allow the sytax below? 为什么SQL解析器允许下面的语法? I would have thought that this would return an error, since the column "3Name" does not exist in the table. 我本以为会返回错误,因为表中不存在“ 3Name”列。

Select 3Name from Employee

它被解释为SELECT 3 AS NAME,因此所有行的结果均为Column'Name'并且值为3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM