Wednesday, 20 July 2016

Table alias and Column alias

Table Alias: 
In General, We know that in police station, criminals will called with alias name eg : Shankar alias shankaranna.

It means some extra name,he is having.Similar to that table also can have another name.

Let's see some example:

SQL > Select * from emp e;

here "e" is alias for emp table. you can specify any alias name but make it simple alias name.

Similar to table alias, we have column alias also in Oracle SQL.

Eg: 

SQL> Select ename EMPLOYEE_NAME FROM EMP;

here EMPLOYEE_NAME is alias for ename column.

Lets see mixed alias combination.

 SQL> Select E.ename EMPLOYEE_NAME,e.sal SALARY FROM EMP e;

 If you are mentioning alias name then it would be better practice to use alias name with dot following column name(eg: e.ename ) for simple query also.

No comments:

Post a Comment