Sunday 3 July 2022

Top 25 SQL Interview Questions and Answers ? Database testing Interview Questions and Answers for QA-SDET-SDE?




SQL Interview Questins & Answers SET-01

Mobile Automation Testing Appium INterview Q&A SET - 01

Top LINUX INterview Questions and Answers

11. What are some of the TCL commands used in Database?

 -  COMMITcommits a Transaction.
ROLLBACKrollbacks a transaction in case of any error occurs. o SAVEPOINT sets a savepoint within a transaction.
SET TRANSACTION specify characteristics for the transaction. 

12. What is stored procedures in SQl, give an example?

Stored Procedures are created to perform one or more DML operations on Database. It is nothing but the group of SQL statements that accepts some input in the form of parameters and performs some task and may or may not returns a value.

Lets first create sample table so that all can practice:

CREATE TABLE Product
(ProductID INT, ProductName VARCHAR(100) )
GO
 
CREATE TABLE ProductDescription
(ProductID INT, ProductDescription VARCHAR(800) )
GO
 
INSERT INTO Product VALUES (680,'HL Lane Frame - Dark, 58')
,(706,'HL Highway Frame - Red, 58')
,(707,'Play-100 Headgear, Crimson')
GO
 
INSERT INTO ProductDescription VALUES (680,'Substitute mount wheel for entry-level rider.')
,(706,'Robust alloy features a quick-release hub.')
,(707,'Streamlined rims for smooth riding.')

Syntax : Creating a ProcedureWe will create a simple stored procedure that joins two tables and returns the result set as shown in the following example.

13. SQL query to list Departments that have less than 3 people in it?

This is a rather simple SQL query interview question to solve. 
You just need to know how to use the COUNT() function and GROUP BY clause.
-- Departments that have less than 3 people in it
SELECT dept_id, COUNT(emp_name) as 'Number of Employee'
FROM Employee
GROUP BY dept_id
HAVING COUNT(emp_name) < 3;

Read more: CLICK HERE

14. What are the different types of join?

Answer:
There are 6 type joins as follow:-
1.Inner join – Will Match exact column data.
2. Left outer join – Will show all the data from the left table which are the match and unmatched.
3.Right outer join – Will show all the data from the right table which are the match and unmatched.
4.Full Outer join – Will show all the data from both tables which are a match and unmatched.
5. Cross join – Will show the product of both tables.
6.Union and Union All – Will combine the data from both.

15.   Write An SQL Query To Determine The Nth (Say N=5) Highest Salary From A Table?

Ans: SQL Query

16. How to detect Deadlock in the DBMS?

Deadlock can be detected by the resource scheduler who checks all the resources allocated to the different processes. The deadlock should be avoided instead of terminating and restarting the transaction so that both resources as well time is not wasted. One of the method used for detecting deadlock is Wait-For-Graph which is suitable for smaller databases.

17.Write An SQL Query To Show Only Even Rows From A Table.
Ans: 
SQL Query

18.What do you mean by “Intrusion Detection” 

Intrusion Detection is the process of finding out an external influence trying to gain illegal access into a software. As its name implies, any form of unlawful access is discovered and reported for necessary action to be taken against the intrusion. It’s like the technology that detects burglary and sounds the alarm. During penetration testing, the company will automatically determine whether the intrusion detection technology in its software is functioning correctly. 

19. Which operator is used to select values within a range?

The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates.

The BETWEEN operator is inclusive: begin and end values are included.

BETWEEN Syntax

-   SELECT column_name(s)
-   FROM table_name
-   WHERE column_name BETWEEN value1 AND value2;
20. What is the difference between HAVING clause and WHERE clause?

Both specify a search condition but HAVING clause is used only with the SELECT statement and typically used with GROUP BY clause.

If GROUP BY clause is not used then HAVING behaves like WHERE clause only.

Here are some other differences:

HAVING filters records that work on summarized GROUP BY results.

HAVING applies to summarized group records, whereas WHERE applies to individual records.

Only the groups that meet the HAVING criteria will be returned.

HAVING requires a GROUP BY clause is present.

WHERE and HAVING can be present in the same query.

21. Write An SQL Query To Fetch Duplicate Records Having Matching Data In Some Fields Of A Table.

Ans: SQL Query


22. Can you join 3 tables together with inner join:

Yes. You can join multiple tables with inner join.

For example, for a Faculty table the lookup tables might be Division, with DivisionID as the PK, Country, with CountryID as the PK, and Nationality, with NationalityID as the PK. To join Faculty to the Division, Country, and Nationality tables, the fields DivisionID, CountryID and NationalityID would need to be foreign keys in the Faculty table.

The SQL to join them would then be:

-   SELECT <fieldlist> FROM Faculty AS f
-   INNER JOIN Division AS d ON d.FacultyID = f.FacultyID
-   INNER JOIN Country AS c ON c.FacultyID = f.FacultyID
-   INNER JOIN Nationality AS n ON n.FacultyID = f.FacultyID
23.  Which SQL statement is used to delete data from a database?

The DELETE statement is used to delete existing records in a table.

DELETE Syntax

-   DELETE FROM table_name
-   WHERE condition;
22.What is CHECK Constraint?

The CHECK constraint is used to limit the value range that can be placed in a column.

If you define a CHECK constraint on a single column it allows only certain values for this column.

If you define a CHECK constraint on a table it can limit the values in certain columns based on values in other columns in the row.

24. Write An SQL Query To Fetch EMPLOYEE Names With Salaries >= 50000 And <= 100000. 

Ans: SQL Query


25. What is a trigger?

Triggers in SQL is kind of stored procedures used to create a response to a specific action performed on the table. You can invoke triggers explicitly on the table in the database.

Triggers are, in fact, written to be executed in response to any of the following events:

A database manipulation (DML) statement (DELETE , INSERT , or UPDATE )

A database definition (DDL) statement (CREATE , ALTER , or DROP ).

A database operation (SERVERERROR , LOGON , LOGOFF , STARTUP , or SHUTDOWN ).

Action and Event are two main components of SQL triggers when certain actions are performed the event occurs in response to that action.

Syntax

-   CREATE TRIGGER name {BEFORE|AFTER} (event [OR..]}
-   ON table_name [FOR [EACH] {ROW|STATEMENT}]
-   EXECUTE PROCEDURE functionname {arguments}

Learn (API-Microservice)Testing+(CoreJava+UI)-SDET with Self Paced Videos and one LIVE Doubt Session

TRANING VIDEOS AVAILABLE with Live Doubt Session @4500/-(course-1 below,API TRaining Videos With ClassNotes and Coding Set) and 6500/- (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122

Entire course content can be found below:  COURSE CONTENT

*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions
Mobile Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Mobile%20Testing


No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

API Status Codes with examples for QA-Testers

  🔺 LinkedIn: https://www.linkedin.com/in/sidharth-shukla-77b53145/ 🔺 Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 🏮In API testing, it...