Thursday, 25 February 2016

DML(SELECT)

SELECT:
SYNTAX:  select  *  from  Table_Name;
This Command is used to retrieve the data from existing table.Using this Command we retrieve all the records from the table and also we can retrieve specific records from the table(using where clause).
Example: Select * from emp; 


  • Here * representd all the columns in the table.
  • ALIAS is a DUPLICATE name or an ALTERNATE name for the original column name or table name or any expression name.
  • Whenever we need to submit understandable or meaning reports to the end user then we need to use ALIAS NAME.
  • We can provide the ALIAS name in three levels: 

  • 1.Column level alias
  • 2.Expression level alias                
3.Table level alias 1.COLUMN LEVEL ALIAS: Providing the alias names for the column as column level alias.

SNYTAX: Select column1 as "alias name",column2 as "alias name",...columnn as"alias name"                    from Table_Name;

EXAMPLE: Select Eid as "Employee_ID",Ename as "Employee_Name",Sal as "SAlary" from                       Emp;

WITH OUT USING AS: Select Eid "Employee_ID",Ename "Employee_Name",Sal "Salary"                                                from Emp;
WITH OUT USING DOUBLE QUOTES(""): 
  Select Eid Employee_Name,Ename Employee_Name,Sal  Salary from Emp;

2.EXPRESSION LEVEL ALIAS:
Providing the alias name for expressions is known as Expression level alias name.

EXAMPLE:select Ename,Eid,Sal,Sal*12  Annual salary from Emp;

NOTE:By using alias Names of Expressions we cannot Perform any Action on/cannot check condition 

Example:Select Ename,Eid,Sal,Sal*12 Annual Salary where Annual Salary>10000;

In above Example error returns as ORA-00904:"Annual salary" :Invalid Identifier.So we cannot Check the Conditions of ALIAS NAMES.  

No comments:

Post a Comment

If you Like my blog Spread it and help friends for whom this blog is useful for their career.