Handouts - 05 (Update - Delete)
Handouts - 05 (Update - Delete)
Note: Follow Handouts & Material & Examples which are discussing in classes to get good knowledge on ETL
Session-5
Topics covered in session:
1. UPDATE Command
2. DELETE Command
3. SELECT Command
4. ORDER BY Clause
5. DISTINCT Operator
Scenario 16: In above table update Ename and Sal for only Eid=2
Update Emp Set Ename=’Y’,Sal=500 Where Eid=2
DELETE: For the purpose of removing data from a table we have to use DELETE command.
Syntax: Delete From Tablename
Scenario 18: From above table delete data for only Eid=2
Delete from Emp where Eid=2
SELECT: For the purpose of retrieving data from a table we have to use SELECT command.
Syntax: Select * from Tablename
Note:
Testing
Scenario 19: From Emp table display all the records in to output screen
Select * From Emp
Follow Handou
Scenario 20: From Emp table display Eid,Ename column records in to output screen
Select Eid,Ename From Emp
Alias Name: After retrieving data from table if you want to display column names as per
your own requirement we need to go for Alias name. To define Alias names we need to use
AS keyword.
Scenario 21: From Emp table display Eid,Ename column records and output columns
should be EMP_ID and EMP_NAME in to output screen
Select Eid as EMP_ID,Ename as EMP_NAME From Emp
ORDER BY: In Teradata whenever we are using SELECT statement to retrieve data, data
will displayed in random order into output screen. If you want to display data in a
particular order we have to use ORDER BY clause.
To sort data in Ascending order we have to give it as ORDER BY Columnname ASC
To sort data in Descending order we have to give it as ORDER BY Columnname DESC.
If we are not giving anything by default it will take it as ASC.
Scenario 22: Display all the records into output screen based on EID column in Desc order.
Select * From Emp ORDER BY Eid Desc
Scenario 23: Display all the records into output screen based on EID column in Desc order
and DID column in Descending order.
Select * From Emp ORDER BY Eid Desc,DID Desc
Note: In Teradata instead of using column names in ORDER BY clause we can give it as
numbers. ( like 1,2,3..)
DISTINCT: For the purpose of retrieving unique records from a particular column we have
to use DISTINCT command.
Scenario 24: From Emp table display all unique departments information.
Select Distinct Did from Emp.
If we are giving Distinct with multiple columns it will find unique records in the
combination of all the columns in Select statement.
Whenever we are using DISTINCT operator compulsory we should have to give it in front of
first column
Teradata Operators: