0% found this document useful (0 votes)
76 views8 pages

ETL Testing Notes

This document provides an overview of key concepts in SQL and database management including: 1. ETL processes involve extracting, transforming, and loading data. OLTP is for transactions and OLAP is for analytics. 2. SQL is the language used to communicate with databases. A DBMS manages databases using relational structures and allows inserting, updating, deleting, and retrieving data. 3. Key SQL commands include DDL, DML, DQL, TCL, and DCL which are used to define, manipulate, query, control transactions, and control access to database objects and data.

Uploaded by

Bharath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views8 pages

ETL Testing Notes

This document provides an overview of key concepts in SQL and database management including: 1. ETL processes involve extracting, transforming, and loading data. OLTP is for transactions and OLAP is for analytics. 2. SQL is the language used to communicate with databases. A DBMS manages databases using relational structures and allows inserting, updating, deleting, and retrieving data. 3. Key SQL commands include DDL, DML, DQL, TCL, and DCL which are used to define, manipulate, query, control transactions, and control access to database objects and data.

Uploaded by

Bharath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

ETL:

Extract
Transform
Loading

OLTP - Transactional
OLAP - Analytical

SQL:

Its language to communicate the database

DBMS - > its based on relational theory is called as relational database management
system.

Database - its collecting meaning full data/ required data

Management System:

its manage the database management should be able to perform below activities:

1.inserting the new data


2.updating the existing data
3.deleting unnecessary data
4.retrieving the require data

SQL Commands:
-------------

What are the commands in SQL

1.DDL (Data Definition Language)


2.DML (Data Manipulation Language)
3.DRL/DQL (Retrieval/query)
4.TCL(Transaction Control Language)
5.DCL (Data Control Language)

DDL - language is used to manage database objects.


*CREATE
*ALTER
*DROP
*TRUNCATE
*RENAME

DML - language is used to manipulate the data u have stored.

*Insert
*Update
*Delete
*Merge

DDL commands worked on Disk of the Database.(Permanent Space)


DML commands worked on RAM buffer under DataBase.(Temporary Space)

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:

to store number/integer data - number


to store text or description - varchar2
to store date info - date (DD-MM-YY)

Create:

Create table emp_Bha_2024


(
id number (4),
name varchar2(10),
rank number(2),
loc varchar2(6)
);

Alter:

Alter+Add
Alter+Modify
Alter+DROP
Alter+RENAME

Modify:
to change datatype size(increase/decrease)

-----
Drop:

to remove database objects like table,view and index.

it will remove table structure and data.

Drop table tablename;


Drop table test;

Rollback --> it will rollback the inserted/updated data into the table.

Commit -> it will commit inserted values into the table.

Can rollback work after commit? - No

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==>

it means old table name to new table name.

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');

select ename,deptno from employee where ename not 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 ename,sal,comm from emp where comm is not null;

select count(*) from emp where comm is null;

select name,mobile_num from DIM_PHONE where mobile_num is null;

SELECT QUERY FLOW:


=================

SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY

SELECT - required columns


FROM - required table names
WHERE - passing filter conditions(optional)
GROUP BY - summary data
HAVING - filtering the data on group by output
ORDER BY - sorting the data in asc or dsc

group functions or aggregate functions:

max()
min()
avg()
sum()
count(*)

dispaly total no of employees by department wise from employee table?

select deptno,count(*) from emp group by deptno;

display maximum salary of the employee by department wise?

select deptno,max(sal) from emp group by deptno;

Display total salary for each department from employee table?


select deptno,sum(sal) from emp group by deptno;

Where cluase ==>

it will filter the data from table.


can we pass where cluase after group by? ==> No

can we pass group functions in the where clause? ==> NO instead of using having
clause

select job, count(*)


from emp
group by job;

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;

select movie, sum(amount)


from dim_movies
where movie in ('RRR','KGF2','SALAR')
group by movie,
having sum(amount)>10000;

SQL Functions:

1.Number Functions

2.Character Functions

3.Date Functions

4.Group Functions

Number Functions:
*****************

*ABS -> it gives absolute values

select abs(-99) from dual;


99

its converting negative values to positive values.

*Mod --> it will give you remainder value.


select mod(5,2) from dual;

MOD(5,2)
-------
1

how to get even or odd records from a table?

query for even records:


select * from
(select rownum r, ename, sal, deptno from emp)
where mod(r,2)=0;

odd records:
select * from
(select rownum r, ename, sal, deptno from emp)
where mod(r,2)=1;

select round(10.98) from dual;

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.

select ceil(2.8) from dual;


3

FLOOR:
------
it will give you nearest least integer value.

select floor(2.8) from dual;


2
Character Functions:
********************

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

select 'C'||' '||'Bharath'||' '|'Reddy' as fullname from dual;


C BHARATH Reddy

5.LENGTH:

select length('Bharath') from dual;

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

what is difference b/w substr and instr?

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

select substr('ABCDEF',2) from dual;


BCDEF

select 'Bharath#REDDY', instr('Bharath#REDDY','#') from dual;


'BHARATH#REDDY' INSTR('BHARATH#REDDY','#')
------------------------------------------
BHARATH#REDDY 7
lpad & rpad:
============
it will add characters to particular column either it from left/right side.

select id,length(ename),lpad(ename,5,0) from emp;

select id,length(ename),rpad(ename,5,'$') from emp;

LTRIM/RTRIM
===========
it removes spaces from the word either it by left/right side.

select ltrim(' arjun') from dual;

select rtrim('arjun ') from dual;

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;

select 'INDIA', truncate('INDIA','IA','XY') from dual;


ans: XNDIY

Date Functions:
===============

You might also like