0% found this document useful (0 votes)
19 views4 pages

Handouts - 05 (Update - Delete)

The document discusses SQL commands like UPDATE, DELETE, SELECT along with clauses like ORDER BY, DISTINCT. It provides examples of using these commands and clauses to manipulate and retrieve data from tables. It also covers Teradata operators and formatting conventions for writing SQL queries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

Handouts - 05 (Update - Delete)

The document discusses SQL commands like UPDATE, DELETE, SELECT along with clauses like ORDER BY, DISTINCT. It provides examples of using these commands and clauses to manipulate and retrieve data from tables. It also covers Teradata operators and formatting conventions for writing SQL queries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Quality Thought ETL Testing Daily Handouts

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

1. Syntax for UPDATE commands:


UPDATE: For the purpose of changing data in table we have to use UPDATE command.
Syntax:
UPDATE Tablename
SET Columnname = Value

Scenario 15: In below table update all Ename values as ‘X’.


Eid Ename Sal Did
1 A 100 10
2 B 200 10
3 C 300 20
4 D 400 20

Update Emp Set Ename = ‘X’

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 17: From above table delete all the records.


Delete from Emp

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

QUALITY THOUGHT * www.facebook.com/qthought * www.qualitythought.in


PH NO: 9963486280, 040-40025423 EMAIL ID: [email protected]
Quality Thought ETL Testing Daily Handouts

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.

Scenario 25: Select Distinct Eid,Did from Emp


It will give unique records in the combination of Eid and Did columns
Note: Follow Hando

QUALITY THOUGHT * www.facebook.com/qthought * www.qualitythought.in


PH NO: 9963486280, 040-40025423 EMAIL ID: [email protected]
Quality Thought ETL Testing Daily Handouts

Whenever we are using DISTINCT operator compulsory we should have to give it in front of
first column

Scnerio 26: Select Eid, Distinct Did,Ename from Emp


This query will through syntax error. We should have to write query as
Select Distinct Eid,Did,Ename from Emp.

Teradata Operators:

In Teradata we are having below operators.

Arithmetic Operators: +,-,*,/


Comparison Operators: >,<,>=,<=,<>,=
Boolean operators: And/ Or/ Not
Between
In / Not In
Is Null / Is Not Null
Like

`Note: F`ollow Handouts

QUALITY THOUGHT * www.facebook.com/qthought * www.qualitythought.in


PH NO: 9963486280, 040-40025423 EMAIL ID: [email protected]
Quality Thought ETL Testing Daily Handouts

QUALITY THOUGHT * www.facebook.com/qthought * www.qualitythought.in


PH NO: 9963486280, 040-40025423 EMAIL ID: [email protected]

You might also like