- The document discusses database testing concepts including CRUD operations, the database testing process, ACID properties, SQL commands like DDL, DML, DCL, and TCL. It covers database objects, constraints, joins, and clauses like where, order by, group by and more. It aims to make the tester technically strong in key database concepts despite perceived negatives around database testing adding bottlenecks or costs. It emphasizes keeping SQL queries simple to prevent defects.
12. www.clariontechnologies.co.in
Syntax :
ALTER TABLE table_name
ADD column_name datatype
Example :
ALTER TABLE Persons
ADD DateOfBirth date
Alter Table
- Mastering Selenium Testing Tools -
Hi Team,
Please refer this link for 1 month Free online Selenium training
course with videos!!!
https://www.linkedin.com/learning/mastering-selenium-testing-
tools/the-course-overview
Thanks
Drop Table
Syntax:
DROP TABLE TableName;
SQL> DROP TABLE CUSTOMERS;
SQL> SHOW CUSTOMERS;
25. REVOKE
Syntax :
REVOKE privilege_name
ON object_name
FROM user_name;
Examples :
SQL> REVOKE privileges ON object FROM user;
SQL> REVOKE ALL ON employees FROM anderson;
SQL> REVOKE SELECT ON employees FROM public;
;
28. www.clariontechnologies.co.in
Order By Clause
Syntax :
SELECT column-list
FROM table_name
[WHERE condition]
[ORDER BY column1, column2, .. columnN] [ASC
| DESC];
SQL> SELECT * FROM CUSTOMERS
ORDER BY NAME, SALARY;
29. www.clariontechnologies.co.in
Group By Clause
Syntax :
SELECT column1, column2
FROM table_name
WHERE [ conditions ]
GROUP BY column1, column2
ORDER BY column1, column2
SQL> SELECT NAME, SUM(SALARY) FROM
CUSTOMERS
GROUP BY NAME;
31. www.clariontechnologies.co.in
Like Clause
Syntax:
The basic syntax of % and _ is as follows:
SELECT FROM table_name WHERE column
LIKE 'XXXX%‘ or
SELECT FROM table_name WHERE column
LIKE '%XXXX%‘ or
SELECT FROM table_name WHERE column
LIKE 'XXXX_‘ or
SELECT FROM table_name WHERE column
LIKE '_XXXX' or
SELECT FROM table_name WHERE column
LIKE '_XXXX_‘
SQL> SELECT * FROM CUSTOMERS
WHERE SALARY LIKE '200%';
32. www.clariontechnologies.co.in
Having Clause
Syntax :
SELECT column1, column2
FROM table1, table2
WHERE [ conditions ]
GROUP BY column1, column2
HAVING [ conditions ]
ORDER BY column1, column2
SQL > SELECT ID, NAME, AGE, ADDRESS,
SALARY
FROM CUSTOMERS
GROUP BY age
HAVING COUNT(age) >= 2;
34. www.clariontechnologies.co.in
Not Null Constraint
By default, a column can hold NULL values. If
you do not want a column to have a NULL
value, then you need to define such constraint
on this column specifying that NULL is now not
allowed for that column.
A NULL is not the same as no data, rather, it
represents unknown data.
36. www.clariontechnologies.co.in
UNIQUE Constraint
The UNIQUE Constraint prevents two
records from having identical values in a
particular column. In the CUSTOMERS
table, for example, you might want to
prevent two or more people from having
identical age.
37. www.clariontechnologies.co.in
Primary Constraint
A primary key is a field in a table which
uniquely identifies each row/record in a
database table. Primary keys must
contain unique values. A primary key
column cannot have NULL values.
38. www.clariontechnologies.co.in
Foreign Key Constraint
A foreign key is a key used to link two
tables together. This is sometimes
called a referencing key.
Foreign Key is a column or a
combination of columns whose values
match a Primary Key in a different
table.
The relationship between 2 tables
matches the Primary Key in one of the
tables with a Foreign Key in the
second table.
39. www.clariontechnologies.co.in
Check Constraints
The CHECK Constraint enables a
condition to check the value being entered
into a record. If the condition evaluates to
false, the record violates the constraint and
isn't entered into the table.
40. www.clariontechnologies.co.in
Joins
Joins clause is used to combine records
from two or more tables in a database. A
JOIN is a means for combining fields from
two tables by using values common to each.
SQL> SELECT ID, NAME, AGE, AMOUNT
FROM CUSTOMERS, ORDERS
WHERE CUSTOMERS.ID =
ORDERS.CUSTOMER_ID;
42. www.clariontechnologies.co.in
CROSS JOIN or CARTESIAN PRODUCT
Syntax :
SELECT table1.column1,
table2.column2... FROM
table1, table2 [, table3 ]
SQL> SELECT ID, NAME,
AMOUNT, DATE FROM
CUSTOMERS, ORDERS;
43. NATURAL JOIN
The SQL NATURAL JOIN is a type of EQUI JOIN and is
structured in such a way that, columns with the same name
of associated tables will appear once only.
Natural Join : Guidelines
- The associated tables have one or more pairs of identically
named columns.
- The columns must be the same data type.
- Don’t use ON clause in a natural join.
Syntax
SELECT * FROM table1 NATURAL JOIN table2;
SQL> SELECT *
FROM foods
NATURAL JOIN company;
www.clariontechnologies.co.in
44. www.clariontechnologies.co.in
INNER JOIN
Syntax :
SELECT table1.column1,
table2.column2...
FROM table1
INNER JOIN table2
ON table1.common_field =
table2.common_field;
SQL> SELECT ID, NAME,
AMOUNT, DATE
FROM CUSTOMERS
INNER JOIN ORDERS
ON CUSTOMERS.ID =
ORDERS.CUSTOMER_ID;
45. www.clariontechnologies.co.in
LEFT JOIN
Syntax :
SELECT table1.column1,
table2.column2...
FROM table1
LEFT JOIN table2
ON table1.common_field =
table2.common_field;
SQL> SELECT ID, NAME,
AMOUNT, DATE
FROM CUSTOMERS
LEFT JOIN ORDERS
ON CUSTOMERS.ID =
ORDERS.CUSTOMER_ID;
46. www.clariontechnologies.co.in
RIGHT JOIN
Syntax :
SELECT table1.column1,
table2.column2...
FROM table1
RIGHT JOIN table2
ON table1.common_field =
table2.common_field;
SQL> SELECT ID, NAME,
AMOUNT, DATE
FROM CUSTOMERS
RIGHT JOIN ORDERS
ON CUSTOMERS.ID =
ORDERS.CUSTOMER_ID;
47. www.clariontechnologies.co.in
FULL JOIN
Syntax :
SELECT table1.column1,
table2.column2...
FROM table1
FULL JOIN table2
ON table1.common_field =
table2.common_field;
SQL> SELECT ID, NAME,
AMOUNT, DATE
FROM CUSTOMERS
FULL JOIN ORDERS
ON CUSTOMERS.ID =
ORDERS.CUSTOMER_ID;
48. www.clariontechnologies.co.in
SELF JOIN
Syntax :
SELECT table1.column1,
table2.column2...
FROM table1
RIGHT JOIN table2
ON table1.common_field =
table2.common_field;
SQL> SELECT ID, NAME,
AMOUNT, DATE
FROM CUSTOMERS
RIGHT JOIN ORDERS
ON CUSTOMERS.ID =
ORDERS.CUSTOMER_ID;
49. Myths or Misconceptions related to Database Testing
• Database Testing requires plenty of expertise and it is a very tedious job
Reality: Effective and efficient Database testing provides long-term functional stability to the overall
application thus it is necessary to put in hard work behind it.
• Database testing adds extra work bottleneck
Reality: On the contrary, database testing adds more value to the overall work by finding out hidden issues
and thus pro-actively helping to improve the overall application.
• Database testing slows down the overall development process
Reality: Significant amount of database testing helps in the overall improvement of quality for the database
application.
• Database testing could be excessively costly
Reality: Any expenditure on database testing is a long-term investment which leads to long-term stability
and robustness of the application. Thus expenditure on database testing is necessary.
www.clariontechnologies.co.in
50. www.clariontechnologies.co.in
• ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties of database transactions.
It allows safe sharing of data.
• Create, Read, Update and Delete (as an acronym CRUD) are the four basic functions of
persistent storage
• With all the features, factors and processes to test on a database, there is an increasing demand
on the tester to be technically strong with the key DB concepts. Despite some of negative beliefs
that the DB testing creates new bottlenecks and is a lot of additional expenditure – this is a realm
of testing that is gaining obvious attention and demand.
• Since your test design would require creating SQL queries, try to keep your queries as simple as
possible to prevent defects in them. It is a good idea for someone other than the author to review
the queries.
SUMMARYSUMMARY