SQL Interview Questions

SQL Interview Questions

Sharing is caring!

If you prefer jobs related to Database then I hope these questions will help you to do your interview better. I have listed the top 25 SQL interview questions with a simple explanation.

1. What is DBMS?

DBMS-Database Management System is a program that helps the user to store, delete, update and retrieve data from a database.

2. What is SQL?

SQL-Structural Query Language is a language specially designed for communicating with the database. It is used to perform the task, such as updating, retrieval, insertion and deletion of data from a database.

3. What is field in database?

A field in database is defined as the area within a record reserved for a specific piece of data.

4. What is RDBMS?

RDBMS-Relational Database Management System is based on the relational model. It stores the data into a collection of tables which are related by common fields.

5.  What is Trigger?

A trigger executes as a response to an action on the table, i.e. insert, delete or update. It is a kind of store procedure and can’t be explicitly invoked.

6. List different kind of SQL’s statements?

  • DDL- Data Definition Language
  • DML-Data Manipulation Language
  • DCL-Data Control Language

7. What is a record in the database?

A record in the database is defined as the collection of values or fields of a specific entity.

8. What is a table in the database?

A table is defined as the collection of records of a specific type.

9.  What is a primary key?

The primary key helps to uniquely identify the items in a table.

10. What is  a foreign key?

The foreign key helps to uniquely identify the items in a different table.

11. What is a constraint?

Constraints are used to specify the limits of the data type of table. It is specified while creating or altering the table statement.

12.  List some samples of constraints?

  • NOT NULL.
  • CHECK.
  • DEFAULT.
  • PRIMARY KEY.
  • FOREIGN KEY.
  • UNIQUE.

13.  Define Join and their different types?

It is used to join two or more tables, The join keyword fetch the data based on the common field between them.

  • Right Join
  • Left Join
  • Inner Join
  • Full Join

14. What is the difference between DELETE and TRUNCATE commands?

DELETE is a DML command and it locks each row in the table for deletions, While TRUNCATE is a DDL command and it locks the table and page but not each row.

sql interview questions

SQL Query

Table Name: Employee

Employee_idFirst nameLast nameSalaryDepartment
1Viratkohli50000Banking
2RockySingh80000Insurance
3JohnMichael70000Banking
4JerryJose60000Insurance
5TomPicaso65000Insurance

15. Query to get all employee details from employee table

16. Get first name ,last name from employee table

17. Get unique Department from employee table

18. Get employee details whose first name is’Tom’

19. Get the employee details whose first name contains ‘E’

20. Get top 2 salary from employee table

21. What is a Relationship and list their types?

The relationship is defined as the connection between the tables in a database. Types of relationships are

  • One to Many Relationship.
  • Many to One Relationship.
  • Self-Referencing Relationship.
  • One to One Relationship.

22. What is a view?

The view in the database is a virtual table based on the set of an SQL statement. It contains rows and columns, just like a real table in the database.

23. How to create table in database?

By using ‘CREATE TABLE’ command table can be created

24. How to create Database?

25. What are the advantages of views in a database?

  • It doesn’t store data in physical location.
  • It can be used to hide some of the columns from the tables
  • It can provide access restriction.

 

Sharing is caring!

Comments are closed.