Thursday, April 22, 2010

Using Aliases

Table aliases (formerly known as correlation names) are "short names" for each table in your FROM clause meant to uniquely identify the data source, but to act as an abbreviation.

When displaying the column name, Oracle uses the uppercase version of the column name as the header.
When using an expression, Oracle strips out the spaces, and uses the expression as the header.
You can provide your own column name using an alias.
Column Aliases
eg:
select sal*2 double_sal from emp;

here double_sal is the alisa name given for sal*2

it shows the output as
double_sal
-----------
16000
32000
45678
Table Aliases

eg:
select t.first_name,t.last_name,t.amount
    from transaction t;
here t is the alias name for  table transaction.
note that the fileld names are specified using alias name