when creating a query what is the purpose of including a column alias
Alias ( SQL ) - wikipedia Alias ( SQL ) Jump to : navigation , search This article needs additional citations for verification . Please help improve this article by adding citations to reliable sources . Unsourced material may be challenged and removed . ( October 2013 ) ( Learn how and when to remove this template message ) An alias is a feature of SQL that is supported by most , if not all , relational database management systems ( RDBMSs ) . Aliases provide database administrators , as well as other database users , with the ability to reduce the amount of code required for a query , and to make queries simpler to understand . In addition , aliasing can be used as an obfuscation technique to protect the real names of database fields . In SQL , you can alias tables and columns . A table alias is also called a correlation name . A programmer can use an alias to temporarily assign another name to a table or column for the duration of a SELECT query . Assigning an alias does not actually rename the column or table . This is often useful when either tables or their columns have very long or complex names . An alias name could be anything , but usually it is kept short . For example , it might be common to use a table alias such as `` pi '' for a table named `` price_information '' . The general syntax of an alias is SELECT * FROM table_name ( AS ) alias_name . Note that the AS keyword is completely optional and is usually kept for readability purposes . Here is some sample data that the queries below will be referencing : Department Table DepartmentID DepartmentName 31 Sales 33 Engineering 34 Clerical 35 Marketing Using a table alias : SELECT D. DepartmentName FROM Department AS D We can also write the same query like this ( Note that the AS clause is omitted this time ) : SELECT D. DepartmentName FROM Department D A column alias is similar : SELECT d. DepartmentId AS Id , d. DepartmentName AS Name FROM Department d In the returned result sets , 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 '' . Also , if only one table is being selected and the query is not using table joins , it is permissible to omit the table name or table alias from the column name in the SELECT statement . Example as follows : SELECT DepartmentId AS Id , DepartmentName AS Name FROM Department d <Th_colspan="2"> SQL Versions SQL - 86 SQL - 89 SQL - 92 SQL : 1999 SQL : 2003 SQL : 2006 SQL : 2008 SQL : 2011 SQL : 2016 Keywords As Case Create Delete From Having Insert Join Merge Null Order by Prepare Select Truncate Union Update Where With Related Edgar Codd Relational database ISO / IEC SQL parts Framework Foundation Call - Level Interface Persistent Stored Modules Management of External Data Object Language Bindings Information and Definition Schemas SQL Routines and Types for the Java Programming Language XML - Related Specifications References ( edit ) Jump up ^ ANSI Standard SQL - Foundation Document - Date : 2010 - 10 - 14 Retrieved from `` https://en.wikipedia.org/w/index.php?title=Alias_(SQL)&oldid=781026809 '' Categories : SQL Hidden categories : Articles needing additional references from October 2013 All articles needing additional references Talk About Wikipedia Українська Edit links This page was last edited on 18 May 2017 , at 17 : 06 . About Wikipedia
1. SQL aliasing in relational database management systems
2. Using aliases to simplify and obfuscate SQL queries
3. Table and column aliases in SQL
4. Syntax and examples of using aliases in SQL queries
5. Benefits and applications of using aliases in SQL