ETL Testing Notes
ETL Testing Notes
Extract
Transform
Loading
OLTP - Transactional
OLAP - Analytical
SQL:
DBMS - > its based on relational theory is called as relational database management
system.
Management System:
its manage the database management should be able to perform below activities:
SQL Commands:
-------------
*Insert
*Update
*Delete
*Merge
Auto Commit/Commit: when u perform dml commands that it will store on buffer(RAM
Buffer) only after using commit then only those will store on Disk.
Datatypes in SQL:
Create:
Alter:
Alter+Add
Alter+Modify
Alter+DROP
Alter+RENAME
Modify:
to change datatype size(increase/decrease)
-----
Drop:
Rollback --> it will rollback the inserted/updated data into the table.
Delete
1.DML
2.Remove data temporarily
3.we can get back data before commit
4.We can remove all or few records
5.where clause will apply
TRUNCATE
1.DDL
2.Remove data permanently
3.we can not get back data
4.we can remove all data
5.where clause won't apply
DROP
1.DDL
2.Remove data and structure
3.we can get using flashback query
4.we can remove all the data
5.where clause not apply
TCL commands:
TRUNCATE
DROP
DCL Commands:
REVOKE
GRANT
how to create a backup table ==> by using general true condition like below:
create table emp_jun_01 as select * from emp_jun where 1=1; ==> it ll create table
with data
create table emp_jun_02 as select * from emp_jun where 1=2; ==> it ll create table
without data means structure only
Rename==>
Special Operators:
IN NOTIN
BETWEEN NOTBETWEEN
LIKE NOTLIKE
IS NULL IS NOT NULL
IN & NOTIN:
==========
select ename,deptno from employee where ename in ('FORD','BLAKE');
BETWEEN NOTBETWEEN:
===================
display employees and their salaries who is getting salary from 2500 to 4000?
select ename,sal from emp where sal between 2500 and 4000;
display employee name which starts with 's' from employee table?
ans:
select * from emp where ename like 'S%';
Null values Handling in database:
---------------------------------
Null Value:
1.Null is undefined value.
2.Null is obscence of value.
3.Every null is unique in database.
4.Null is not equal to zero.
5.Null is not equal to Null.
6.If we perform any operation with null values then result is Null only.
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
max()
min()
avg()
sum()
count(*)
can we pass group functions in the where clause? ==> NO instead of using having
clause
select job,count(*)
from emp
where job in ('clerk','salesman')
group by job;
select job,count(*)
from emp
group by deptno
having count(*)>5;
display total customers from DIM_CUST table for only Bangalore and Chennai which
has more than 25000 customers above locations?
select loc,count(*)
from DIM_CUST
where loc in ('BANGALORE',"CHENNAI')
group by loc
having count(*)>25000;
SQL Functions:
1.Number Functions
2.Character Functions
3.Date Functions
4.Group Functions
Number Functions:
*****************
MOD(5,2)
-------
1
odd records:
select * from
(select rownum r, ename, sal, deptno from emp)
where mod(r,2)=1;
ROUND(10.98)
------------
11
select trunc(10.988,2) from dual; ===> it will make value into two decimal values.
TRUNC(10.988,2)
---------------
10.98
GREATEST:
--------
select least(10,20,90,100) from dual; it will give u max / great value from the
list
100
LEAST:
------
select least(10,20,90,100) from dual; it will give u min / least value from the
list
10
CIEL:
----
it will give you nearest greatest integer value.
FLOOR:
------
it will give you nearest least integer value.
1.lower
select ename,lower(ename) from emp;
2.upper
select ename, upper(ename) from emp;
3.initcap
select initcap('state bank of india') from dual; --> First letter of word will be
capital letter
INITCAP('STATEBANKOFINDIA)
--------------------------
State Bank Of India
4.CONCAT:
select concat('C','Bharath') from dual; --> it will take 2 expressions only and
concatenate two words only
CBHARATH
5.LENGTH:
LENGTH('BHARATH')
=================
5
display employees which has more than 5 characters in their names from employee
table?
select ename,length(ename)
from emp
where length(ename)>5?
6.SUBSTR
substr instr
1.display some part of the string 1.display position of the character
from a string
from main string
2. substr output is varchar2 2.instr output is number
LTRIM/RTRIM
===========
it removes spaces from the word either it by left/right side.
REPLACE
=======
changing character by string AND
string by string
India - Bharath
TRANSLATE
=========
changing character by character only.
I - J
select '[email protected]',
replace('[email protected]','gmail','yahoo')
from dual;
Date Functions:
===============