SQL Topics
SQL Interview Questions Beginner
title: SQL Interview Questions Beginner
Congratulations!
You have completed:
SQL Basics
SQL Intermediate
SQL Advanced
SQL OptimizationNow it's time to prepare for:
Interviews
Technical Tests
Viva Exams
Campus PlacementsThis section contains the most frequently asked SQL interview questions.
These questions are suitable for:
Freshers
Students
Internship Interviews
Junior Developers
Campus PlacementsWhat Will You Learn?
This chapter covers:
SQL Fundamentals
Database Concepts
Keys
Constraints
Queries
Joins
Indexes
Transactionsalong with interview-style answers.
Q1. What is SQL?
Answer
SQL stands for:
Structured Query LanguageIt is a standard language used to:
Store Data
Retrieve Data
Update Data
Delete Data
Manage DatabasesExample
SELECT *
FROM Employees;Q2. What are the main categories of SQL commands?
Answer
SQL commands are divided into:
DDL
DML
DQL
DCL
TCLDDL
CREATE
ALTER
DROP
TRUNCATEDML
INSERT
UPDATE
DELETEDQL
SELECTDCL
GRANT
REVOKETCL
COMMIT
ROLLBACK
SAVEPOINTQ3. What is a Database?
Answer
A database is an organized collection of related data that can be easily stored, managed, and retrieved.
Example
Student Database
Bank Database
Hospital DatabaseQ4. What is a Table?
Answer
A table is a collection of rows and columns used to store data in a database.
Example
| EmployeeID | EmployeeName |
|---|---|
| 1 | Rahul |
| 2 | Priya |
Q5. What is a Row?
Answer
A row represents a single record in a table.
Example:
1 Rahulis one row.
Q6. What is a Column?
Answer
A column represents a specific attribute of data.
Example:
EmployeeID
EmployeeName
SalaryQ7. What is a Primary Key?
Answer
A Primary Key uniquely identifies each record in a table.
Features:
Unique
Cannot Be NULL
One Primary Key Per TableExample:
EmployeeID INT PRIMARY KEYQ8. What is a Foreign Key?
Answer
A Foreign Key creates a relationship between two tables.
Example:
DepartmentID INT,
FOREIGN KEY
(
DepartmentID
)
REFERENCES Departments
(
DepartmentID
)Q9. Difference Between Primary Key and Foreign Key?
| Feature | Primary Key | Foreign Key |
|---|---|---|
| Uniqueness | Yes | No |
| NULL Allowed | No | Yes |
| Purpose | Identify Row | Create Relationship |
Q10. What is a Constraint?
Answer
Constraints are rules applied to columns to maintain data integrity.
Examples:
PRIMARY KEY
FOREIGN KEY
UNIQUE
CHECK
DEFAULT
NOT NULLQ11. What is NOT NULL Constraint?
Answer
Ensures a column cannot contain NULL values.
Example:
Name VARCHAR(100)
NOT NULLQ12. What is UNIQUE Constraint?
Answer
Ensures all values in a column are unique.
Example:
Email VARCHAR(100)
UNIQUEQ13. What is the Difference Between DELETE, TRUNCATE, and DROP?
| Feature | DELETE | TRUNCATE | DROP |
|---|---|---|---|
| Removes Rows | Yes | Yes | Yes |
| Removes Table | No | No | Yes |
| WHERE Allowed | Yes | No | No |
| Rollback Possible | Yes* | Depends | No |
Q14. What is the Difference Between CHAR and VARCHAR?
CHAR
Fixed Length
Example:
CHAR(10)VARCHAR
Variable Length
Example:
VARCHAR(10)Q15. What is NULL?
Answer
NULL represents missing, unknown, or unavailable data.
Example:
Phone Number Not ProvidedQ16. What is the Difference Between NULL and 0?
NULL
Unknown Value
0
Actual Numeric Value
Q17. What is SQL JOIN?
Answer
JOIN combines data from multiple tables based on a related column.
Example:
SELECT *
FROM Employees E
JOIN Departments D
ON E.DepartmentID =
D.DepartmentID;Q18. What are Different Types of JOINs?
Types
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL JOIN
SELF JOIN
CROSS JOINQ19. What is INNER JOIN?
Answer
Returns only matching rows from both tables.
Example:
SELECT *
FROM Employees E
INNER JOIN Departments D
ON E.DepartmentID =
D.DepartmentID;Q20. What is LEFT JOIN?
Answer
Returns all rows from the left table and matching rows from the right table.
Q21. What is RIGHT JOIN?
Answer
Returns all rows from the right table and matching rows from the left table.
Q22. What is FULL OUTER JOIN?
Answer
Returns all rows from both tables whether matched or not.
Q23. What is a Subquery?
Answer
A query inside another query.
Example:
SELECT *
FROM Employees
WHERE Salary >
(
SELECT AVG(Salary)
FROM Employees
);Q24. What is the Difference Between WHERE and HAVING?
WHERE
Filters rows before grouping.
HAVING
Filters groups after grouping.
Example:
SELECT DepartmentID,
COUNT(*)
FROM Employees
GROUP BY DepartmentID
HAVING COUNT(*) > 5;Q25. What is GROUP BY?
Answer
GROUP BY groups rows with similar values.
Example:
SELECT DepartmentID,
COUNT(*)
FROM Employees
GROUP BY DepartmentID;Q26. What is ORDER BY?
Answer
Used to sort data.
Example:
SELECT *
FROM Employees
ORDER BY Salary DESC;Q27. What is DISTINCT?
Answer
Removes duplicate values.
Example:
SELECT DISTINCT DepartmentID
FROM Employees;Q28. What is an Index?
Answer
An Index improves query performance by allowing faster data retrieval.
Example:
CREATE INDEX IX_Email
ON Employees(Email);Q29. What is a View?
Answer
A View is a virtual table based on a query.
Example:
CREATE VIEW HighSalaryEmployees AS
SELECT *
FROM Employees
WHERE Salary > 50000;Q30. What is Normalization?
Answer
Normalization organizes data to reduce redundancy and improve integrity.
Common Forms:
1NF
2NF
3NF
BCNFQ31. What is Denormalization?
Answer
Denormalization combines tables to improve read performance.
Q32. What is a Transaction?
Answer
A transaction is a sequence of SQL operations executed as a single unit.
Example:
BEGIN;
UPDATE Accounts
SET Balance = Balance - 100;
UPDATE Accounts
SET Balance = Balance + 100;
COMMIT;Q33. What are ACID Properties?
Answer
A → Atomicity
C → Consistency
I → Isolation
D → DurabilityQ34. What is COMMIT?
Answer
Saves transaction changes permanently.
Example:
COMMIT;Q35. What is ROLLBACK?
Answer
Undo changes made during a transaction.
Example:
ROLLBACK;Q36. What is a Stored Procedure?
Answer
A stored procedure is a saved SQL program stored inside the database.
Q37. What is a Trigger?
Answer
A trigger automatically executes when an event occurs.
Example:
INSERT
UPDATE
DELETEQ38. What is a View vs Table?
| Feature | View | Table |
|---|---|---|
| Stores Data | No | Yes |
| Virtual | Yes | No |
| Query Based | Yes | No |
Q39. What is SQL Injection?
Answer
A security attack where malicious SQL code is inserted into queries.
Example:
' OR 1=1 --Q40. How Can SQL Injection Be Prevented?
Answer
Use:
Beginner Interview Quick Revision
Remember:
✓ SQL = Structured Query Language
✓ PK = Unique Identifier
✓ FK = Relationship
✓ JOIN = Combine Tables
✓ INDEX = Faster Search
✓ VIEW = Virtual Table
✓ TRANSACTION = Group Of Operations
✓ ACID = Transaction Properties
✓ NORMALIZATION = Reduce Redundancy
✓ SQL INJECTION = Security RiskMost Asked Fresher Questions
What is SQL?
What is a Database?
What is a Primary Key?
What is a Foreign Key?
Difference Between DELETE/TRUNCATE/DROP?
What is a JOIN?
What is an Index?
What is a View?
What is Normalization?
What are ACID Properties?Summary
These beginner-level SQL interview questions cover the fundamental concepts every SQL developer, fresher, and student should know. Mastering these questions provides a strong foundation for technical interviews, campus placements, and database-related roles.
In this lesson, you learned:
- 40 Beginner SQL Interview Questions
- Keys and Constraints
- Joins
- Transactions
- Views
- Indexes
- Normalization
- SQL Security
- Frequently Asked Interview Topics
Next Step
Continue to the next lesson:
SQL Interview Questions (Intermediate) →
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for SQL Interview Questions Beginner.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this SQL topic.
Search Terms
sql, sql complete guide, sql tutorial, sql notes, complete, guide, interview, questions
Related SQL Topics