Alias (SQL): Difference between revisions

Content deleted Content added
No edit summary
style; no need for abbreviation as abbreviation isn't used a second time; wikified
Line 1:
An alias is a feature of SQL that is supported by most, if not all, [[RDBMS|relational database management systems (RDBMSs)]].
<br />
Aliases provide [[Databasedatabase administrator|Database Administrators (DBAs)]]s, as well as other database users, with two things:
 
# Reduces the amount of code required for a query, and
Line 11:
# Column aliases
 
You can give another name to a table (for the duration of the [[Select (SQL)|SELECT query]]) by using an alias.
''This does not rename the database table!''
 
Line 44:
A column alias is similar:
SELECT d.DepartmentId AS Id, d.DepartmentName AS Name FROM Department d
In the returned [[result setsset]]s, the data shown above would be returned, with the only exception being "DepartmentID" would show up as "Id", and "DepartmentName" would show up as "Name".
<br><br>
Also, if only one table is being selected and the query is not using [[Join (SQL)|table joins]], it is permissible to omit the table name or table alias from the column name in the SELECT statement. Example as follows: