Header Ads

Header ADS

Column Alias

Column Alias in Oracle SQL


Topic Introduction: To give the meaningful name of the selected column on SQL Query we column alias. if we use an expression on Oracle SQL Query its column name will be very long and look very odd to us for use. In this situation, Alias has an important role in giving a meaningful name. A description and example have been given below.





A column alias:

  • To rename a column heading.
  • This action is particularly handy for calculations.
  • The new name directly follows the original column name, and you may optionally use the 'AS' keyword in between.
  • If the new name contains spaces, or special characters, or is case-sensitive, it must be enclosed in double quotation marks.

Column headings may lack descriptive names, making them challenging to comprehend. To enhance clarity, we can employ a column alias.

To specify an alias, place it after the column in the SELECT list, separated by a blank space. By default, alias headings are displayed in uppercase. If the alias includes spaces, or special characters (e.g., # or $), or is case-sensitive, it should be enclosed in double quotation marks ("").



SELECT  last_name "Name" , salary*12 "Annual Salary"
FROM employees;

Column_Alias



The example displays the last names and annual salaries of all the employees. Because the Annual Salary contains a space, it has been enclosed in double quotation marks. Note that the column heading in the output is exactly the same as the column alias.

No comments

Theme images by Deejpilot. Powered by Blogger.