Top 250 SQL Interview Questions and Answers
Updated 16 Jul 2025

Asked in Virtusa Consulting Services

Yes, I can create 2 tables in SQL and perform operations like INSERT, SELECT, UPDATE, and DELETE.
Create Table 1: CREATE TABLE employees (id INT, name VARCHAR(50), salary DECIMAL(10,2));
Create Table 2: CREATE TABLE departments (dept_id INT, dept_name ...read more

Asked in TCS

Q. What is the difference between Truncate and Delete operations?
Truncate is a DDL operation that removes all records from a table, while Delete is a DML operation that removes specific records.
Truncate is faster than Delete as it does not log individual row deletions.
Truncate resets identity columns, while Delete...read more

Asked in Bazar India and 3 others

Q. What is the use of a pivot table?
A pivot table is a data summarization tool used in spreadsheet programs to organize and analyze large amounts of data.
Pivot tables allow users to quickly summarize and analyze data from different perspectives.
They can be used to group and aggregate d...read more

Asked in BT Business

Q. What is SP3 architecture?
SP3 architecture is a security architecture designed to protect against malware attacks.
SP3 stands for Security Platform 3
It is a hardware-based security architecture
It is designed to protect against malware attacks by isolating critical system compo...read more
Asked in KNACKBOUT STUDIO

Q. How would you create a website with a MySQL database?
Create a website with a MySQL database.
Choose a web development framework (e.g., Django, Ruby on Rails)
Design the database schema and create the necessary tables
Write server-side code to handle HTTP requests and interact with the database
Implement us...read more

Asked in IBM

Q. What is the full form of DML?
DML stands for Data Manipulation Language.
DML is a subset of SQL (Structured Query Language) used to manipulate data in a database.
It includes commands like INSERT, UPDATE, DELETE, and SELECT.
DML statements are used to add, modify, or delete data in ...read more

Asked in Cognizant

Q. What is the difference between implicit and explicit cursors?
Implicit cursors are automatically created by the Oracle server, while explicit cursors are explicitly declared by the programmer.
Implicit cursors are used for single-row queries, while explicit cursors are used for multi-row queries.
Implicit cursors...read more

Asked in Cirrius

Q. What are SQL and PL/SQL, and how do they differ?
SQL is a language used to manage relational databases, while PL/SQL is a procedural language used to enhance SQL functionality.
SQL is used to create, modify, and query databases
PL/SQL is used to create stored procedures, functions, and triggers
SQL is...read more

Asked in Cognizant

Q. Explain SQL join statements.
SQL join statements are used to combine rows from two or more tables based on a related column between them.
Join statements are used to retrieve data from multiple tables in a single query.
Common types of join statements include INNER JOIN, LEFT JOIN...read more

Asked in Fidelity Investments

Q. Write a SQL query joining two tables on a key column.
Join two tables on a key column using SQL
Use the JOIN keyword followed by the name of the second table
Specify the key column in both tables using the ON keyword
Choose the type of join (INNER, LEFT, RIGHT, FULL) based on your requirement
SQL Jobs




Asked in Xerago

Q. How do you remove duplicates from a table?
To remove duplicates from a table, use the DISTINCT keyword in a SELECT statement.
Identify the columns that contain duplicates.
Use the DISTINCT keyword in a SELECT statement to retrieve only unique values.
Create a new table with the unique values or ...read more


Q. Given two tables and four outputs, identify the type of join for each output.
Identifying type of join for given outputs of two tables.
Inner join: returns only the matching rows from both tables.
Left join: returns all rows from left table and matching rows from right table.
Right join: returns all rows from right table and matc...read more
Asked in Webelight Solutions

Q. How do you select a particular row in SQL?
To select a particular row in SQL, use the SELECT statement with the WHERE clause.
Use the SELECT statement to retrieve data from a table.
Specify the table name and column names in the SELECT statement.
Use the WHERE clause to filter the rows based on ...read more

Asked in Customer Centria

Q. What is the difference between a system table and a transactional table?
System tables store metadata about the database system while transactional tables store data related to transactions.
System tables contain information about the database schema, users, permissions, and other system-related data.
Transactional tables s...read more

Asked in Orient Technologies

Q. What is the difference between Measures and Columns in Power BI?
Measures are calculations based on aggregated data, while columns are static data columns.
Measures are dynamic and change based on filters and slicers
Columns are static and do not change based on filters and slicers
Measures are used for calculations ...read more

Asked in CitiusTech

Q. What does it mean if a table or view does not exist?
It means that the table or view does not exist in the database.
The query will fail and return an error message.
The application may crash or behave unexpectedly.
The table or view may have been deleted or renamed.
Check the spelling and syntax of the qu...read more

Asked in TCS

Q. What is dbms , Sql query
DBMS stands for Database Management System. SQL is a programming language used to manage and manipulate data in a DBMS.
DBMS is a software system that allows users to create, manage, and manipulate databases.
SQL is used to communicate with a DBMS and ...read more

Asked in AT&T

Q. Tell me about your experience with SQL performance optimization.
I have extensive experience in performance optimization in SQL.
Identifying and optimizing slow queries
Creating and maintaining appropriate indexes
Using query execution plans to identify bottlenecks
Optimizing database schema and table design
Using appr...read more

Asked in Capgemini

Q. List all languages available in SQL.
List of SQL languages
MySQL
Oracle
PostgreSQL
Microsoft SQL Server
SQLite

Asked in M Tech Innovations

Q. What is SQL replication, and what are the different types of SQL replication?
SQL replication is the process of copying data from one database to another. There are three types of SQL replication: snapshot, transactional, and merge.
Snapshot replication copies a snapshot of the entire database at a specific point in time.
Transa...read more

Asked in Publicis

Q. What are constraints in SQL Server?
Constraints are rules that are enforced on the data in a table.
Constraints ensure data integrity and consistency.
They can be used to enforce rules such as uniqueness, primary key, foreign key, etc.
Constraints can be added to a table during creation o...read more

Asked in EPAM Systems

Q. What is a window function in SQL?
Window function in SQL is used to perform calculations across a set of table rows related to the current row.
Window functions are applied to a set of rows related to the current row, known as a window frame.
They can be used to calculate running total...read more

Asked in Metaminds Software Solutions

Q. What is ORM in SQL?
ORM (Object-Relational Mapping) is a programming technique for converting data between incompatible type systems in SQL databases.
ORM allows developers to interact with a database using object-oriented programming languages.
It abstracts the database ...read more

Asked in QuickXpert Infotech

Q. What are subqueries in SQL?
Subqueries in SQL are queries nested within another query. They can be used to retrieve data for further analysis or filtering.
Subqueries are enclosed within parentheses and can be used in SELECT, FROM, WHERE, and HAVING clauses.
They can be used to r...read more
Asked in RBHU Analytics

Q. What is the difference between the EXISTS and IN operators?
The 'exists' operator is used to check for the existence of a field in a document, while the 'in' operator is used to match a field against a list of values.
The 'exists' operator is used in MongoDB to check if a field exists in a document.
The 'in' op...read more

Asked in TCS

Q. What are table partitions?
Table partitions are a way to divide a large table into smaller, more manageable parts.
Table partitions help improve query performance by allowing data to be stored and accessed more efficiently.
Partitions can be based on a range of values (e.g. date...read more

Asked in Accenture

Q. What are the differences between the DELETE and TRUNCATE commands?
Delete command is used to remove specific rows from a table, while truncate command is used to remove all rows from a table.
Delete command is a DML (Data Manipulation Language) statement.
Delete command can be used with a WHERE clause to specify the r...read more

Q. Can you provide examples of union and intersection operations?
Union and intersection are set operations used in mathematics and computer science.
Union combines two sets and removes duplicates
Intersection returns the common elements between two sets
Example of union: {1,2,3} union {3,4,5} = {1,2,3,4,5}
Example of ...read more

Asked in Chetu

Q. What is a DDL command in SQL?
DDL stands for Data Definition Language and is used to create, modify, and delete database objects in SQL.
DDL commands include CREATE, ALTER, and DROP.
CREATE is used to create a new database object like a table or index.
ALTER is used to modify an exi...read more

Asked in Avanade

Q. How do you connect to a SQL server using Python?
To connect to a SQL server using Python, you can use the pyodbc library.
Install pyodbc library using pip
Import pyodbc module in your Python script
Establish a connection using the pyodbc.connect() method, providing the necessary connection details
Crea...read more
Top Interview Questions for Related Skills
Interview Experiences of Popular Companies










Interview Questions of SQL Related Designations



Reviews
Interviews
Salaries
Users

