我的一个专栏叫。我不能改名字,因为不是我做的。 我是否允许做一些像SELECT from TableName或有一个特殊的语法,以避免SQL Server混淆?


当前回答

在Apache Drill中,使用反引号:

select `from` from table;

其他回答

在Oracle SQL Developer中,pl/ SQL可以使用双引号,但如果使用双引号,则必须以大写字母输入列名。例如,从MY_TABLE中选择“FROM”

简单的解决方案

假设列名是from;因此,查询中的列名可以通过表别名引用

Select * from user u where u.from="US"

将列名像这样用括号括起来,from变成[from]。

select [from] from table;

也可以使用以下命令(在查询多个表时很有用):

select table.[from] from table;

嗨,我在完全符合ANSI标准的Teradata系统上工作。使用双引号“”来命名这样的列。

例如,type是一个SQL保留关键字,当在引号中使用时,type被视为用户指定的名称。

参见下面的代码示例:

CREATE TABLE alpha1
AS
(
SEL
product1
type_of_product AS "type"
FROM beta1
) WITH DATA
PRIMARY INDEX (product1)

--type is a SQL reserved keyword

TYPE

--see? now to retrieve the column you would use:

SEL "type" FROM alpha1

在Apache Drill中,使用反引号:

select `from` from table;