Top 10 SQL Interview Questions & Answers
As a candidate for SQL (Web development / DB) you would definitely like to know the best possible questions you might face in your next interview. Thought the questions change from one interviewer to another, we would like to put together a set of questions considering that it is expected from you to know the correct answers to these questions.
List of SQL Freelancers
Question 1
What is SQL and where is it used?
Answer: SQL stands for ‘Structured Query Language’ and it is used to communicate with the Database. This is a standard language for working with relational database management systems. It is used to perform insert, update, and delete tasks on a database.
*Tip: Remember, don’t forget the basics of a technology you are using and answer to a question with acronym is not just telling its long form!
Question 2
Which are standard SQL commands which you can use with most of the RDBMS systems?
Answer: Select, Insert, Update, Delete, Create and Drop are standard SQL commands you can use with most RDBMS using SQL
*Tip: Unless you are asked to give ‘syntax’ of a command, you don’t need to get into exact syntax but if asked, be prepared to explain / write the same.
Question 3
What is a Primary Key and a Foreign Key in SQL DB?
Answer: 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 foreign key is a column (or columns) that references a column (most often the primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the data.
*Tip: There could be many questions on how the data is fetched and referenced into another tables
Question 4
What is a database Schema?
Answer: A database schema is the skeleton structure that represents the logical view of the entire database. It defines how the data is organized and how the relations among them are associated. It formulates all the constraints that are to be applied on the data.
*Tip: Questions related to architecture or structure of RDBMS system will be common in any interview.
Question 5
What is database normalization?
Answer: Database normalization is a technique by which an existing schema is modified to minimize redundancy and dependency of data
*Tip: techniques to data management are favourite questions for many interviewers
Question 6
What is a DB view and how it is different than a Table?
Answer: In SQL, a view is a virtual table based on the result-set of an SQL statement. A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database
*Tip: Consider other questions also about comparison between two similar entities
Question 7
What is a stored procedure?
Answer: Stored Procedure is a function consists of many SQL statement to access the database system. Several SQL statements are consolidated into a stored procedure and execute them whenever and wherever required.
*Tip: The way writing single queries is important, knowledge of stored procedure is also equally important.
Question 8
Which all open source Relational Databases you are aware of?
Answer: SQLite, MySQL (most popular) and PostgreSQL are common open source RDBMS systems
*Tip: Here you can add a few lines about the one which you have used.
Question 9
What is SQL Union Operator? What does it do?
Answer: The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements. It removes duplicate rows between the various SELECT statements. Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
*Tip: As you go on answering the earlier questions correctly, the complexity or depth of questions will go on increasing but it helps your overall interview ratings.
Question 10
Write an SQL Query to find an employee whose salary is equal to or greater than 50000
Answer: SELECT EmpName FROM Employee WHERE Salary>=50000;
Bonus Question
Write an SQL Query to find names of employees whose first name starts with K
Answer: SELECCT * FROM Employee WHERE EmpFirstName like ‘K%’;
*Tip: The examples given here are only to let you know a common type of question in SQL interviews. Be prepared to write much complex queries even if it’s not a written test.
We hope you have got the gist of important questions which can help you prepare for your interview
All the Best!
Pingback: Technical Writing – CDeo Writing()