Showing posts with label SQL interview questions for testers. Show all posts
Showing posts with label SQL interview questions for testers. Show all posts

Tuesday, January 2, 2018

Basic SQL Interview Questions & Answers for Software Testers

1. What is the difference between Delete and Drop commands?

Delete Command:
  • Delete removes the data from the table and the structure of the table will be retained.
  • This is a DML command.
  • Rollback is possible.
Drop Command:
  • Drop permanently removes both the data as well as the structure of the table.
  • This is a DDL command.
  • Rollback is not possible.
2. What is the difference between Delete and Truncate commands?

Delete Command:
  • Delete command deletes only the rows from the table based on the condition given in the where clause and also it deletes all the rows from the table if no condition is specified.
  • It does not free the space containing the table.
Truncate Command:
  • Truncate command is used to delete all the rows from the table and free the space containing the table.
3. What is a primary key?

A primary key is a combination of fields which uniquely specify a row. Primary key values cannot be NULL.

4. What is a foreign key?

The relationship needs to be created between two tables by referencing foreign key with the primary key of another table.

5. What is Joins in SQL?

Joins are used to combines the results of two tables. It combines the data based on the relationship between tables.

6. What are the different types of joins in SQL?

Following are the most commonly used joins in SQL:
  1. Inner Join
  2. Right Join
  3. Left Join
  4. Full Join
  5. Left Outer Join
  6. Right Outer Join
7. What is Inner Join in SQL?

Inner join returns matching rows between the two tables.

8. What is the difference between BETWEEN and IN condition operators?

The BETWEEN operator is used to display the rows based on a range of values. 
Examples:
Select * from blogs where pageviews BETWEEN 10 AND 20;

The IN condition operator is used to check for values contained in a specific set of values.
Examples:
Select * from blogs where country IN ('Germany', 'France', 'UK');

9. Is it possible for a table to have more than one foreign key? 

Yes, A table can have many foreign keys and only one primary key.