我应该始终完全限定SQL中的列名吗? [英] Should I Always Fully Qualify Column Names In SQL?

查看:65
本文介绍了我应该始终完全限定SQL中的列名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用SQL语句时,出于兴趣,我应该始终使用完全限定的列名(tablename.columnname),即使仅使用一个表也是如此,例如

Out of interest when working with SQL statements should I always use the fully qualifed column name (tablename.columnname) even if only working with one table e.g.

SELECT table.column1, table.column2 FROM table


推荐答案

最好这样做-不会增加任何复杂性,并且可以防止将来出现错误。

It's better if you do - it doesn't add any complexity, and it can prevent errors in the future.

系统,您不应该拥有-就像编程语言中的名称空间一样。理想的情况是不要有冲突,但是会过多使用显式名称,从而使代码混乱。

But in a well-defined system, you shouldn't have to - it's like namespaces in programming languages. The ideal is not to have conflicts, but it can clutter the code with the superfluous use of explicit names.

-Adam

这篇关于我应该始终完全限定SQL中的列名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆