命名子查询与使用 AS 别名子查询结果有什么区别?

what is the difference between naming a subquery vs using AS to alias the subquery result?

这两种语法有区别吗?

select * from (some query) result
select * from (some query) AS result

以上两种说法没有区别。 "AS" 只是提及别名的一种更明确的方式。

两者在功能上没有区别(他们做同样的事情)。

然而,一些数据库有这样或那样的偏好。例如,Oracle 不支持 as 用于 table 别名。另一方面,MS Access 需要它们。

就个人而言,我只使用 as 作为列别名。我将它们用作列别名,因为很容易遗漏一列,所以:

select x y

即使您的意思是:

也有效
select x, y

as 别名的意向声明。

from 子句中没有这种混淆的危险,所以我发现 as 对于 table 别名是不必要的。