Top 250 SQL Interview Questions and Answers

Updated 16 Jul 2025

Q. Can you create 2 tables in SQL and perform different operations on them?
Ans.

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

2w ago

Q. What is the difference between Truncate and Delete operations?

Ans.

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

1w ago

Q. What is the use of a pivot table?

Ans.

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

2d ago

Q. What is SP3 architecture?

Ans.

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

Are these interview questions helpful?
3d ago

Q. How would you create a website with a MySQL database?

Ans.

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

1w ago

Q. What is the full form of DML?

Ans.

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

Share interview questions and help millions of jobseekers 🌟
man with laptop

Asked in Cognizant

2w ago

Q. What is the difference between implicit and explicit cursors?

Ans.

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

1d ago

Q. What are SQL and PL/SQL, and how do they differ?

Ans.

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

1w ago

Q. Explain SQL join statements.

Ans.

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

3d ago

Q. Write a SQL query joining two tables on a key column.

Ans.

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

DHL Global Forwarding India logo
Senior Application Support Specialist 3-5 years
DHL Global Forwarding India
4.2
Chennai
DHL Global Forwarding India logo
Principal DevOps Engineer 10-15 years
DHL Global Forwarding India
4.2
Indore
DHL Global Forwarding India logo
Software Engineer (Azure BI) 2-7 years
DHL Global Forwarding India
4.2
Chennai

Asked in Xerago

2w ago

Q. How do you remove duplicates from a table?

Ans.

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.

Ans.

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

1d ago

Q. How do you select a particular row in SQL?

Ans.

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

1w ago

Q. What is the difference between a system table and a transactional table?

Ans.

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

1w ago

Q. What is the difference between Measures and Columns in Power BI?

Ans.

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

4d ago

Q. What does it mean if a table or view does not exist?

Ans.

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

2w ago

Q. What is dbms , Sql query

Ans.

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

6d ago

Q. Tell me about your experience with SQL performance optimization.

Ans.

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

3d ago

Q. List all languages available in SQL.

Ans.

List of SQL languages

  • MySQL

  • Oracle

  • PostgreSQL

  • Microsoft SQL Server

  • SQLite

1w ago

Q. What is SQL replication, and what are the different types of SQL replication?

Ans.

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

1w ago

Q. What are constraints in SQL Server?

Ans.

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

2d ago

Q. What is a window function in SQL?

Ans.

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

Q. What is ORM in SQL?

Ans.

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

2w ago

Q. What are subqueries in SQL?

Ans.

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

3d ago

Q. What is the difference between the EXISTS and IN operators?

Ans.

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

1w ago

Q. What are table partitions?

Ans.

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

5d ago

Q. What are the differences between the DELETE and TRUNCATE commands?

Ans.

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?

Ans.

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

1w ago

Q. What is a DDL command in SQL?

Ans.

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

2w ago

Q. How do you connect to a SQL server using Python?

Ans.

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

Previous
1
2
3
4
5
6
7
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Accenture Logo
3.7
 • 8.7k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6.1k Interviews
Cognizant Logo
3.7
 • 5.9k Interviews
Capgemini Logo
3.7
 • 5.1k Interviews
Tech Mahindra Logo
3.5
 • 4.1k Interviews
HCLTech Logo
3.5
 • 4.1k Interviews
LTIMindtree Logo
3.7
 • 3k Interviews
Deloitte Logo
3.7
 • 3k Interviews
View all
Interview Tips & Stories
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
SQL Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 Lakh+

Reviews

10L+

Interviews

4 Crore+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits