T-SQL - 使用“="的别名;与“作为" [英] T-SQL - Aliasing using "=" versus "as"
问题描述
在为列设置别名时,是否有任何特殊原因(性能或其他原因)在 = 之前使用 AS?
Is there any particular reason (performance or otherwise) to use AS ahead of = when aliasing a column?
我个人的偏好(为了可读性)是使用这个:
My personal preference (for readability) is to use this:
select
alias1 = somecolumn
alias2 = anothercolumn
from
tables
etc...
而不是这个:
select
somecolumn as alias1
anothercolumn as alias2
from
tables
etc...
我是否错过了不应该这样做的任何原因?在格式化列时,其他人的偏好是什么?
Am I missing out on any reason why I shouldn't be doing this? What are other people's preferences when it comes to formatting their columns?
推荐答案
‘=' 不是有效的 ANSI SQL,因此如果您希望在不同的 DBMS 上运行您的应用程序,将会遇到困难.
‘=’ isn't valid ANSI SQL, so you'll have difficulty should you wish to run your application on a different DBMS.
(当使用 ANSI 格式但省略了可选的AS"时,我发现结果很难阅读,个人而言.)
(It's when ANSI form is used but the optional ‘AS’ is omitted I find the results difficult to read, personally.)
这篇关于T-SQL - 使用“="的别名;与“作为"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!