You can rename a table or a column temporarily by giving another name known as alias. The term alias means an alternate name. Here’s an example of how to use a column alias
SELECT empno,hiredate,sal, ename AS 'Name' FROM emp;
Notice that the column alias of ‘Name’ is surrounded by single quotes. The output is:
The fourth column now has a header. The keyword AS is used to specify a column alias, which immediately follows the keyword. Be noted that the AS keyword is optional. You can omit the AS keyword in the column alias. If the column alias contain space but it must be enclosed in quotes.
In addition to providing alternate names for columns, aliases can also be specified for tables, using the same AS keyword. There are three general reasons for using table aliases.
The first reason relates to tables with obscure or complex names. For example, if a table is named emp, you can use the following SELECT to give it an alias of emp.
SELECT ename FROM emp AS ;
Unlike column aliases, table aliases are not enclosed in quotes. When using table aliases, you have the option of using the alias as a prefix for any selected columns.
For example, the above could also be written as:
SELECT e.ename FROM emp AS e;
The prefix Orders has now been added as a prefix to ename, using a period to separate the prefix from the column name. In this situation, the prefix wasn’t necessary. However, when data is selected from multiple tables, the prefix will sometimes be required.