Should I Always Fully Qualify Column Names In SQL?

后端 未结 11 1186
小鲜肉
小鲜肉 2021-02-14 02:48

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.



        
11条回答
  •  面向向阳花
    2021-02-14 03:30

    I would say it is nice to use qualified name, it adds readability to your code. It does not make much sense to use it for single table but for multiple tables it is must. if table names are too big then it is recommended to use alias, alias should preferably be derived from table name.

    SELECT Dep.Name,Emp.Name
    FROM Department DEP INNER JOIN Employee Emp
    ON Dep.departmentid=Emp.DepartmentID 
    

提交回复
热议问题