You are on page 1of 27

Functional Testing

1. B
2. I
3. E
4. D/B
5. S
6. C

Database Testing

Sign Up form – Check on UI (Front End)

FN- M

LN- C

Email- CM

Mb. No-12

Address-Pune

Submit

“Sign up is successful” – we can check for success message

Database-

Customer Sign Up Table

- Validate correctness & completeness

Database/ Backend Testing

Database- storage location – collection of related data

1. Structured data- Facebook, filpkart, amazon, MSEB, MPSC, IRCTC


2. Unstructured data- Random data- social media post- Data cannot be stored in DB

Database management system (DBMS)

- To perform any operations on the data we need the DBMS


- Different database- Oracal, sql server, My Sql, MangoDB
When we deal with structured data we use RDBMS

What is SQL-

SQL – Structured Query Language

It is designed for managing data in a RDBMS

Pronounced- SQL or See-Qwell

SQL- is a database language / not the database

SQL- used

- Database creation
- deletion
- Fetching row
- Modifying row

Why SQL is required

- To create database/table
- To insert record
- To update record
- To delete records
- To retrieve data

SQL Syntax

SQL follows some unique set of rules & regulation called syntax

SQL- is not case sensitive. Generally SQL keywords are written in Uppercase

SQL Statement

SQL statement are stared with any of the SQL command/keyword

Iike- SELECT, INSERT, UPDATE, DELETE, ALTER, DROP


Statement ends with a semicolon (;)

Ex. SELECT “Column name” FROM “table name”;

Why use semicolon?

Used to separate SQL statement

SQL Commands / Keyword

Select- extract data from the database

Update- update data in database

Delete-

Create table-

Alter table-

Drop table-

Inert in to –

SQL Commands- are instruction. It is used to communicate with the database also used to
perform specific task

Types of SQL commands

Five types of SQL commands

1. DDL- data definition language


2. DML- data manipulation language
3. DCL- data control language
4. TCL – transaction control language
5. DQL- data query language

DDL- data definition language

- Changes the structure of the table like creating a table, delete a table, altering table etc….
- All DDL command- auto committed – means – it permanently save all the changes in the
database
- DDL commands
1. Create
2. Alter
3. Drop
4. Truncate

DML- data manipulation language

- DML commands used to modify the database


- DML- not auto committed- means it can’t permanently save all the changes in the
database
- They can be rollback
- DML – commands
1. Insert
2. Update
3. Delete

Data query language

- DQL is used to fetch the data from the database/ table


- DQL command
1. Select

Database- collection of data- storage – no of table – row (records) & column (field)

Ex. Sign up, login credentials, orders, employee info, student’s registration

Table Name- Sign Up – front end- UI- ID,FN,LN,MObNo,EmailID, City- submit- successful

ID FN LN MobNo EmailId City

1 Rahul Gandhi 1111 1@gmail.com Pune

2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 Anna Hajare 3333 3@gmail.com Pune

4 Sharad Pawar 4444 4@gmail.com Baramati

5 Soniya Gandhi 5555 5@gmail.com Pune


1. SQL SELECT statement
- Fetch the data from the database
- Retrieve the data from the database
- Following sql statement selects or fetch the record in the sign up table

SELECT Syntax

SELECT * FROM tablename;

Example

SELECT * FROM SIgnUP;

Output

We get the all the records from the tables

ID FN LN MobNo EmailId City

1 Rahul Gandhi 1111 1@gmail.com Pune

2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 Anna Hajare 3333 3@gmail.com Pune

4 Sharad Pawar 4444 4@gmail.com Baramati

5 Soniya Gandhi 5555 5@gmail.com Pune

* - rows & column select

Select particular column in the table

For EX. select FN & LN column

Syntax

SELECT column1, column2….n FROM tablename;

or

SELECT column1, column2….N

FROM tablename;
Example-

SELECT FN, LN FROM SignUP;

Or

SELECT FN, LN

FROM SignUP;

Output-

FN LN

1 Rahul Gandhi

2 Arvind Kejriwal

3 Anna Hajare

4 Sharad Pawar

5 Soniya Gandhi

2. Distinct
- Keyword / statement is used to return only distinct value/ different value/ unique value in
the particular column
- Table – column- many duplicate value – sometimes we want only unique value
- Ex. LN – distinct value select

Syntax

SELECT DISTINCT column 1, 2, 3….n

FROM tablename;

Example

SELECT DISTINCT LN FROM SignUp;

Output
LN

1 Gandhi

2 Kejriwal

3 Hajare

4 Pawar

Count

Syntax

SELECT COUNT (DISTINCT column 1, 2, 3….n)

FROM tablename;

Example

SELECT COUNT (DISTINCT LN) FROM SignUp;

Output

Number of records- 4

Without Distinct

SELECT coumnname 1, 2…n FROM tablename;

Example

SELECT LN FROM SignUp;

Output

LN

1 Gandhi

2 Kejriwal

3 Hajare
4 Pawar

5 Gandhi

TOP (SQL server)

SQL statement it used to display the top records in a table

Syntax

SELECT TOP value/number/percentage * FROM tablename;

Example

SELECT TOP 3 * FROM SignUp;

SELECT TOP 50% * FROM SignUp;

Output

ID FN LN MobNo EmailId City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 3 Anna Hajare 3333 3@gmail.com Pune

RONUM(Oracal)

SELECT * FROM tablename

Where RONUM<=value;

SELECT * FROM SignUp

Where RONUM<=3;

ID FN LN MobNo EmailId City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai


3 3 Anna Hajare 3333 3@gmail.com Pune

Limit (MySql)

SELECT * FROM tablename

LIMIT value;

SELECT * FROM SignUp

LIMIT 2;

Output

ID FN LN MobNo EmailId City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

ORDER BY

Order by keyword – it used to sort the result set in ascending & descending order

It is used to display the records by ascending & descending order from selected column

Default- Ascending order

DESC- Descending order

Ascending order

SELECT * FROM tablename

ORDERBY column 1,2,3….n;


SELECT * FROM SignUp

ORDERBY FN;

ID FN LN MobNo EmailId City

1 3 Anna Hajare 3333 3@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 1 Rahul Gandhi 1111 1@gmail.com Pune

4 4 Sharad Pawar 4444 4@gmail.com Baramati

5 5 Soniya Gandhi 5555 5@gmail.com Pune

Descending order

SELECT * FROM tablename

ORDERBY column name DESC;

SELECT * FROM SignUp

ORDERBY FN DESC;

ID FN LN MobNo EmailId City

2 5 Soniya Gandhi 5555 5@gmail.com Pune

1 4 Sharad Pawar 4444 4@gmail.com Baramati

3 1 Rahul Gandhi 1111 1@gmail.com Pune

4 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

5 3 Anna Hajare 3333 3@gmail.com Pune


Where clause

- Where clause is used to filter records


- It is used to extract only those records that fulfill a specified condition
- EX. Sign Up- City- Pune

SELECT * FROM tablename

WHERE condition;

CIndition= (Column name = value)

SELECT * FROM SignUp

WHERE City=Pune;

ID FN LN MobNo EmailId City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 3 Anna Hajare 3333 3@gmail.com Pune

3 5 Soniya Gandhi 5555 5@gmail.com Pune

SELECT * FROM tablename

WHERE Columnane=value;

SELECT * FROM SignUp

WHERE ID=1;

ID FN LN MobNo EmailId City


1 1 Rahul Gandhi 1111 1@gmail.com Pune

SELECT coulmn1 ,2,3…FROM tablename

WHERE condition;

SELECT email id FROM SignUp

WHERE City=Pune;

Email Id
1 1@gmail.com
2 3@gmail.com
3 5@gmail.com

Type of Where Clause

1. Or
2. And

Logic gates

OR- 1 1 =1 1 0 =1 0 1 =1 0 0 =0

AND- 1 1 =1 1 0 =0 0 1 =0 0 0 =0

OR-

Use to select records when both condition or one condition is true

SELECT * FROM tablename

WHERE condition 1 OR condition 2;


SELECT * FROM SignUP

WHERE FN=’Rahul’ OR LN=’Gandhi’;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 5 Soniya Gandhi 5555 5@gmail.com Pune

SELECT column name 1,2, FROM tablename

WHERE condition 1 OR condition 2;

SELECT emaild FROM SignUp

WHERE FN=Rahul OR LN= Gandhi;

Email Id
1 1@gmail.com
2 5@gmail.com

AND

- Select records when both the condition must be true the we get the output will be true

SELECT * FROM tablename

WHERE condition 1 AND condition 2;

SELECT * FROM SignUp


WHERE FN=Rahul AND LN=Gandhi;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune


SELECT column 1, 2 FROM tablename

WHERE condition 1 AND condition 2;

SELECT Mob.No FROM SignUp

WHERE FN=Rahul AND LN=Gandhi;

Mob. No

1 1111

Like Operator

Start name S/B/

End Name H

Like operator it is used in a where clause to search for a specified pattern in a column

1. % -----multiple characters
2. _ ------ single character

For starting with specific alphabets

SELECT * FROM tablename

WHERE columnname LIKE pattern;

SELECT * FROM SignUp

WHERE FN LIKE ‘A%’;


ID FN LN Mob. No Email Id City

1 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

2 3 Anna Hajare 3333 3@gmail.com Pune

SELECT columnname FROM tablename

WHERE columnname LIKE pattern;

SELECT LN FROM SignUp

WHERE FN LIKE ‘A%’;

LN

1 Kejriwal

2 Hajare

For ending with specific alphabets

SELECT * FROM tablename

WHERE columnname LIKE pattern;

SELECT * FROM SignUp

WHERE FN LIKE ‘%d’;

ID FN LN Mob. No Email Id City

1 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

2 4 Sharad Pawar 4444 4@gmail.com Baramati


SELECT columnname FROM tablename

WHERE columnname LIKE pattern;

SELECT LN FROM SignUp

WHERE FN LIKE ‘%d’;

LN

1 Kejriwal

2 Pawar

A%d

[ABC]%

%[ABC]

SELECT * FROM tablename

WHERE columnname NOT LIKE pattern;

SELECT * FROM SignUp

WHERE FN NOT LIKE ‘A%’;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 4 Sharad Pawar 4444 4@gmail.com Baramati


3 5 Soniya Gandhi 5555 5@gmail.com Pune

Select all records where the value of the column starts with the letter "A".

Syntax

SELECT * FROM table_name
WHERE column LIKE “A%”;

Select all records where the value of the column ends with the letter "a".

Syntax

SELECT * FROM table_name
WHERE column LIKE “%a”;

Select all records where the value of the column starts with letter "A" and ends with the
letter "b".

Syntax

SELECT * FROM table_name
WHERE column LIKE “A%b”;

Select all records where the value of the column contains the letter "a".

Syntax

SELECT * FROM table_name
WHERE column LIKE “%a%”;

Select all records where the value of the column does NOT start with the letter "A".
Syntax

SELECT * FROM table_name
WHERE column NOT LIKE “A%”;

For Starting with alphabets ABC

The following SQL statement selects all Sign Up with a FN starting with "A", "B", or "C":

Syntax

SELECT * FROM table_name
WHERE column LIKE “[ABC]%”;

For Ending with alphabets ABC

The following SQL statement selects all Sign Up with a FN ending with "A", "B", or "C":

Syntax

SELECT * FROM table_name
WHERE column LIKE “%[ABC]”;

LIKE Operator Description


WHERE Column LIKE 'a%' Finds any values that start with "a"
WHERE Column LIKE '%a'
Finds any values that end with "a"

WHERE Column LIKE '%or%' Finds any values that have "or" in any position
WHERE Column LIKE '_r%'
Finds any values that have "r" in the second
position

WHERE Column LIKE 'a_%'


Finds any values that start with "a" and are at
least 2 characters in length

WHERE Column LIKE 'a__%' Finds any values that start with "a" and are at
least 3 characters in length
WHERE Column LIKE 'a%o' Finds any values that start with "a" and ends
with "o"

Wildcard operator

- Used to substitute one or more characters in a string


- Like operator –wildcard
- Like operator – where clause to search specified pattern

SELECT * FROM tablename


WHERE colunmname Like specified pattern;

SELECT * FROM SignUp


WHERE FN LIKE ‘_ahul’;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

IN operator
- Used to fetch one or more data from the table
- It is use to select those records which specify in query

SELECT * FROM tablename

WHERE Columnname IN (‘Value1’,’value2’,’value3’….);

SELECT * FROM SignUp

WHERE FN IN (‘Rahul’,’Soniya’);

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 5 Soniya Gandhi 5555 5@gmail.com Pune

SELECT * FROM tablename

WHERE Columnname NOT IN (‘Value1’,’value2’,’value3’….);

SELECT * FROM SignUp

WHERE FN NOT IN (‘Rahul’,’Soniya’);

ID FN LN Mob. No Email Id City

1 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

2 3 Anna Hajare 3333 3@gmail.com Pune

3 4 Sharad Pawar 4444 4@gmail.com Baramati


Between Operator

- Selects values within a given range


- Value- number, text, date
- Include- begin & end value are included
- It is use to select value between ranges which specified

SELECT * FROM tablename

WHERE coumnname BETWEEN value1 AND value2;

SELECT * FROM SignUp

WHERE ID BETWEEN 2 AND 4;

ID FN LN Mob. No Email Id City

1 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

2 3 Anna Hajare 3333 3@gmail.com Pune

3 4 Sharad Pawar 4444 4@gmail.com Baramati

SELECT * FROM SignUp

WHERE EmailId BETWEEN ‘1@gmail.com’ AND ‘3@gmail.com’;

ID FN LN Mob. No Email Id City

1 Rahul Gandhi 1111 1@gmail.com Pune

2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 Anna Hajare 3333 3@gmail.com Pune

NOT between
SELECT * FROM SignUp

WHERE ID NOT BETWEEN 2 AND 4;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 5 Soniya Gandhi 5555 5@gmail.com Pune

INSERT INTO

- INSERT INTO statement is used to insert new records in a table

INSERT INTO tablename

VALUES (value1, value2, value3…..)

INSERT INTO SignUp

VALUES (6, “Jayant”, “Patil”, 6666, 6@gmail.com, “Sangli”);

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 3 Anna Hajare 3333 3@gmail.com Pune

4 4 Sharad Pawar 4444 4@gmail.com Baramati

5 5 Soniya Gandhi 5555 5@gmail.com Pune

6 6 Jayant Patil 6666 6@gmail.com Sangli


Only insert data in specific column

INSERT INTO tablename (column1, coulmn2,coulmn3…)

VALUES (value1, value2, value3…)

INSERT INTO SignUp (FN,LN,Mob.No)

VALUES (“Amit”, “Deshmukh”, 7777);

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 3 Anna Hajare 3333 3@gmail.com Pune

4 4 Sharad Pawar 4444 4@gmail.com Baramati

5 5 Soniya Gandhi 5555 5@gmail.com Pune

6 6 Jayant Patil 6666 6@gmail.com Sangli

7 Amit Deshmukh 7777

UPDATE

- It is used to modify the existing records in a table

Ex. FN=Rahul ----Mob.No=0000, Email id=0@gmail.com, City=Delhi

UPDATE tablename

SET coulmn1=value1, coulmn2=value2….

WHERE codition;
UPDATE SignUp

SET Mob.No=0000, Email Id=0@gmail.com, City=Delhi

WHERE FN=Rahul;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 0000 0@gmail.com Delhi

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 3 Anna Hajare 3333 3@gmail.com Pune

4 4 Sharad Pawar 4444 4@gmail.com Baramati

5 5 Soniya Gandhi 5555 5@gmail.com Pune

UPDATE SignUp

SET Mob.No=0000, Email Id=0@gmail.com, City=Delhi

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 0000 0@gmail.com Delhi

2 2 Arvind Kejriwal 0000 0@gmail.com Delhi

3 3 Anna Hajare 0000 0@gmail.com Delhi

4 4 Sharad Pawar 0000 0@gmail.com Delhi

5 5 Soniya Gandhi 0000 0@gmail.com Delhi

Condition= Coumnname=value

Delete

- It is used to delete existing records in table


- Used the particular row in to the table
- Ex. delete Mob.No=2222 from the SignUp table

DELETE FROM tablename

WHERE condition;

DELETE FROM SignUp

WHERE Mob.No=2222;

ID FN LN Mob. No Email Id City

1 Rahul Gandhi 1111 1@gmail.com Delhi

3 Anna Hajare 3333 3@gmail.com Pune

4 Sharad Pawar 4444 4@gmail.com Baramati

5 Soniya Gandhi 5555 5@gmail.com Pune

DELETE FROM SignUp

ID FN LN Mob. No Email Id City

SELECT INTO

- Select statement it is used to copies data from one table into a new table

SELECT * INTO newtablename FROM oldtablename;

SELECT*INTO Register FROM SignUp;


Tablename- Register

ID FN LN Mob. No Email Id City

1 Rahul Gandhi 1111 1@gmail.com Pune

2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 Anna Hajare 3333 3@gmail.com Pune

4 Sharad Pawar 4444 4@gmail.com Baramati

5 Soniya Gandhi 5555 5@gmail.com Pune

ALIAS

SQL statement it is used for to change the temporary column name & table name without
changing the database

SELECT coumnname AS aliasname

FROM tablename;

SELECT FN AS Firstname, LN AS Lastname

FROM SignUp;

ID Firstname Lirstname Mob. No Email Id City

1 Rahul Gandhi 1111 1@gmail.com Pune

2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 Anna Hajare 3333 3@gmail.com Pune

4 Sharad Pawar 4444 4@gmail.com Baramati

5 Soniya Gandhi 5555 5@gmail.com Pune


SELECT coumnname AS aliasname

FROM tablename AS aliastable;

SELECT FN AS Firstname, LN AS Lastname

FROM SignUp AS Register;

Tablename- Register

ID Firstname Lastname Mob. No Email Id City

1 Rahul Gandhi 1111 1@gmail.com Pune

2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 Anna Hajare 3333 3@gmail.com Pune

4 Sharad Pawar 4444 4@gmail.com Baramati

5 Soniya Gandhi 5555 5@gmail.com Pune

UNION & UNION ALL

- It is used to combine the result set of two or more select statement


- Same number of column
- Same data type
- Same order

You might also like