Hello Friends, In this tutorial, I am going to write some SQL Interview Questions and Answers.
SQL Interview Questions and Answers:
1) What is RDBMS?
Relational Data Base Management Systems (RDBMS) that maintains data records and indices in tables. Relationships may be created and maintained across and among the data and tables.
2) What is SQL?
SQL stands for ‘Structured Query Language’ which is developed by IBM in 1970’s. SQL is used to access and manipulate the database.
3) What is a SELECT statement?
The SELECT statement allows you to select data from the database. The data returned is stored in the result table is called the result-set.
4) What is normalization?
Database normalization, or simply normalization, is the process of organizing the columns (attributes) and tables (relations) of a relational database to reduce data redundancy and improve data integrity.
5) What is the INSERT statement?
The INSERT statement allows us to insert data or information into a database.
6) How can we delete a record from a database?
DELETE statement allows you to delete records or any specific records from the database.
7) How can find the total number of records in a database table?
COUNT function is used to count the total number of records in a database table.
SELECT COUNT(*) FROM Employee
8) What is View?
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.
9) What is Index?
An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently.
10) What is GROUP BY?
The GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.
11) What is the difference between “dropping a table”, “truncating a table” and “deleting all records” from a table?
Dropping: (Table structure + Data are deleted), Invalidates the dependent objects, Drops the indexes
Truncating: (Data alone deleted), Performs an automatic commit, Faster than delete
Delete: (Data alone deleted), Doesn’t perform automatic commit
12) What’s the difference between a primary key and a unique key?
Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default.
Another major difference is that primary key doesn’t allow NULLs, but unique key allows one NULL only.
13) What are triggers? How to invoke a trigger on demand?
Triggers are special kind of stored procedures that get executed automatically when a DML operation is performed
Triggers can’t be invoked on demand. The Trigger is invoked only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.
14) What is a join and explain different types of joins?
Join is used in queries to explain how different tables are related. Joins also let us select data from a table depending upon data from another table.
Types of joins:
15) What is a self-join?
A self-join is similar to any other join, except that two instances of the same table will be joined in the query.
- Interview Questions and Answers on Method and Property in .NET.
- Introduction to REST and HTTP.
- Views in SQL Server.
- Triggers in SQL Server
I hope this post is useful for you. I would appreciate your feedback, comments, and suggestions.