SQL Interview Questions and Answers

SQL (Structured Query Language) interview questions

These SQL questions have been designed for various interviews, competitive exams and entrance tests. We have covered questions on both basic and advanced concepts which will help you improve your skills to face interview questions on SQL, Structured Query Language.

Who is this SQL interview questions designed for?

All the experienced programmer, database administrator, database developers, DBA, tester, web developers, application developers, programmers and software engineer will find these questions extremely useful. All freshers, BCA, BE, BTech, MCA and college students wanting to make a career in front end designing will be highly benefited by these questions.

SQL interview questions topics

This section covers SQL topics like - SQL Select, Order By, Insert Into, DML, DDL, DCL, Opertors, Joins, Union, Group By, Exists, Constraints, Not Null, Unique, Primary Key, Foreign Key, Check, Default, Index, Auto Increment, Dates, Views etc.

1. What is DBMS?

Answer:

A database management system (DBMS) enables users to create, read, update and delete data in a database. It lets end users use data while managing data integrity. It stores data that can be shared by multiple users in a controlled manner concurrently.

2. What is RDBMS?

Answer:

A relational database management system (RDBMS) is based on the relational model. This model uses relationship between tables using primary keys, foreign keys and indexes.

RDBMS uses constraints of primary and foreign keys to establish relationships between rows of data in different database tables. It uses the concept of normalization to eliminate the need to redundantly store related data in multiple tables.

3. What is SQL?

Answer:

SQL stands for Structured Query Language, is a language to communicate with the Database. It performs tasks such as retrieval, updation, insertion and deletion of data from a database.

4. What is a primary key?

Answer:

A primary key is a unique identifier that uniquely identify a record in a database table. It has implicit NOT NULL constraint (means primary key values can't be NULL).

5. What is the unique key?

Answer:

A Unique key ensures rows are unique within the database. It provides uniqueness of the column on which it is defined.

6. Difference between a Primary Key and a Unique Key.

Answer:

A primary key job is to uniquely identify a row within a table while a Unique key ensures additional unique conditions on column(s).

A primary key enforces entity integrity whereas Unique key enforces unique data.
There may be many unique key constraints for one table, but only one PRIMARY KEY constraint for one table.

Primary key doesn't allow NULLs, but unique key allows one NULL only.

Primary key creates a clustered index on the column by default, whereas unique creates a non-clustered index by default.

7. What is a foreign key?

Answer:

A foreign key is a column or group of columns that establishes a link between the data in two tables. A foreign key ensures referential integrity of the data.