Jan 15, 2019

10 SQL Interview Questions You Need to Be Ready For

If you're preparing for a job interview, then you're likely practicing questions that can help the interviewer get a better picture of you and your skills. If the job you're interviewing for requires the use of SQL, then you should be prepared to answer basic questions that show off your knowledge. Make sure you're prepared by knowing the answers to these 10 SQL interview questions.

1. What is SQL?

SQL is short for Structured Query Language and is the computer language used to communicate with a database. People use SQL statements to update or retrieve information from a database. It is a universal language that almost all databases use.

2. What is a primary key?

A primary key is a column that uniquely specifies a row in a table. Primary keys cannot have NULL values. While a table cannot have more than one primary key, two or more columns can make up the primary key. If it is made up of multiple columns, it's known as a composite primary key.

3. What is a unique key?

The unique key uniquely identifies each record in the table. Unlike a primary key, it can have multiple values defined in one table, and NULL values are allowed.

4. What is a database?

A database is an organized form of data that's easy to access, store, manage, and retrieve. It might also be a collection of tables, schema, and other database objects.

5. What are DBMS and RDBMS?

DBMS stands for Database Management System. It's a collection of programs that allows people to store, retrieve, update, or remove information from the database. RDBMS stands for Relational Database Management System. This model stores the information in a collection of tables, and users can access the information using SQL.

6. What are tables and fields in SQL?

A table is a set of data that has been organized into columns and rows. The field is the space in a table where a row and a column intersect, and this is where a record or data is stored in the table.

7. What are the types of joins in SQL?

A join combines rows from multiple tables. It can merge two tables or retrieve information. The types of joins are inner, right, left, and full.

8. What are query and subquery?

A query is a piece of code used to retrieve information from a database. A subquery is a query inside a query. The outer query is called the main query, and the inner query is the subquery. Subqueries are executed first and then the results are inserted into the main query.

9. What are the differences between delete and truncate commands?

A delete command removes a single row in a table, whereas a truncate command removes all the rows from a table. You can roll back information from a delete command but not from a truncate command. The performance of a truncate command is faster than a delete command because it maintains minimal log.

10. What is an index?

An index is a data structure that allows for faster retrieval of data from the database. The three types of indexes are unique, clustered, and non-clustered.

If you're interviewing for a job as a Data Analyst or Data Scientist, knowing the basics of SQL is a must. Visit Udacity's Nanodegree programs to get the skills and training you need to move forward on your career path.

Sources: