使用不带 AS 的别名

Mal*_*tha 11 postgresql alias

我从参考注释中找到了以下查询,我可以看到将lineitem表命名为l1并将lineitem表命名为l2。

select avg(l_extendedprice) from lineitem l1
where l_extendedprice =
(select min(l_extendedprice) from lineitem l2
where l1.l_orderkey = l2.l_orderkey);
Run Code Online (Sandbox Code Playgroud)

这是一个有效的别名方法,无需显式使用AS?如果这不是 Postgres 中的别名,那么这个约定是什么?

Lau*_*lbe 14

SQL 标准允许您使用带或不带AS.

不同之处在于,如果没有AS,则无法使用 PostgreSQL 关键字作为别名,请参阅文档。所以始终使用更安全AS。