By using SQL, you can specify aliases (alias) for column names and table names.
In fact, there are three ways to alias the Select column, and these three methods are not applicable to all databases.
Method one, directly after the field name alias, the middle is separated by a space.
Method Two, specify the field alias with the AS keyword, as between the field of the select and the alias.
When an alias is not enclosed in double quotation marks, it displays the result in uppercase. If the alias contains special characters, or if you want the aliases to appear as they are, you will enclose the aliases in double quotation marks.
Select Empno as "Employee number", ename name, (sal+500) *12 "annual Salary" from EMP;
Method three, for SQL Server also provides another method, with the "=" number is specified. The "=" number is placed between the field and the alias of the Select.
Example:
SQL Server |
Oracle |
Select emp_id as EmpId , emp_name "Employee Name" , Extemsion=ext , SUBSTRING (emp_id,1.2) "to job year" From Employee where dept_id= ' I200 ' |
Select emp_id as EmpId , emp_name "Employee Name" , Extemsion Ext , SUBSTR (emp_id,1.2) "to job year" From Employee where dept_id= ' I200 ' |
In an Oracle database, a data table alias cannot be added as, for example:
Select A.appname from AppInfo a;--correct
Select A.appname from appinfo as a;--error
Note: This may be a problem in order to prevent a conflict with the keyword as in a stored procedure in an Oracle database.
http://blog.163.com/magicc_love/blog/static/185853662201210161442254/
SQL alias parsing (reprint)