SQL Interview Questions for Beginners


🔹 1. What is SQL?

SQL (Structured Query Language) is used to store, retrieve, and manage data in relational databases.


🔹 2. What is a database?

A database is an organized collection of data stored electronically.


🔹 3. What is DBMS?

DBMS (Database Management System) is software used to manage databases (e.g., MySQL, Oracle).


🔹 4. What is RDBMS?

RDBMS stores data in tables with rows and columns and supports relationships between tables.


🔹 5. Difference between DBMS and RDBMS?

DBMSRDBMS
No relationshipsSupports relationships
No constraintsUses keys & constraints

🔹 6. What is a table?

A table is a collection of related data in rows and columns.


🔹 7. What is a row?

A row represents a single record in a table.


🔹 8. What is a column?

A column represents a field or attribute in a table.


🔹 9. What is a primary key?

A primary key uniquely identifies each record in a table.


🔹 10. What is a foreign key?

A foreign key links one table to another.


🔹 11. What are SQL commands?

SQL commands are:

  • DDL (CREATE, DROP, ALTER)
  • DML (INSERT, UPDATE, DELETE)
  • DQL (SELECT)
  • TCL (COMMIT, ROLLBACK)

🔹 12. What is SELECT query?

Used to fetch data from a table.

SELECT * FROM students;

🔹 13. What is WHERE clause?

Used to filter records.

SELECT * FROM students WHERE age > 18;

🔹 14. What is INSERT statement?

Used to add data into table.

INSERT INTO students VALUES (1, 'Amit', 20);

🔹 15. What is UPDATE statement?

Used to modify existing data.

UPDATE students SET age = 21 WHERE id = 1;

🔹 16. What is DELETE statement?

Used to remove records.

DELETE FROM students WHERE id = 1;

🔹 17. What is DROP?

Deletes entire table permanently.


🔹 18. What is TRUNCATE?

Removes all records but keeps table structure.


🔹 19. Difference between DELETE and TRUNCATE?

DELETETRUNCATE
Removes selected rowsRemoves all rows
Can use WHERECannot use WHERE

🔹 20. What is ORDER BY?

Used to sort data.

SELECT * FROM students ORDER BY age ASC;

🔹 21. What is GROUP BY?

Groups rows with same values.


🔹 22. What is HAVING?

Used with GROUP BY for filtering groups.


🔹 23. What is JOIN?

Used to combine rows from multiple tables.


🔹 24. Types of JOIN?

  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL JOIN

🔹 25. What is INNER JOIN?

Returns only matching records.


🔹 26. What is LEFT JOIN?

Returns all records from left table + matching from right.


🔹 27. What is RIGHT JOIN?

Returns all records from right table + matching from left.


🔹 28. What is FULL JOIN?

Returns all records from both tables.


🔹 29. What is alias in SQL?

Temporary name for table or column.


🔹 30. What is DISTINCT?

Removes duplicate records.


🔹 31. What is constraint?

Rules applied on table columns.


🔹 32. Types of constraints?

  • NOT NULL
  • UNIQUE
  • PRIMARY KEY
  • FOREIGN KEY
  • CHECK
  • DEFAULT

🔹 33. What is NULL?

Represents missing or unknown value.


🔹 34. What is indexing?

Improves search speed in database.


🔹 35. What is view?

A virtual table based on SQL query.


🔹 36. What is stored procedure?

A pre-written SQL code saved for reuse.


🔹 37. What is trigger?

Automatically executes when event occurs.


🔹 38. What is normalization?

Process of organizing data to reduce redundancy.


🔹 39. Types of normalization?

  • 1NF
  • 2NF
  • 3NF

🔹 40. What is denormalization?

Adding redundancy to improve performance.


🔹 41. What is subquery?

A query inside another query.


🔹 42. What is alias for table?

Temporary name for table.


🔹 43. What is case statement?

Used for conditional logic in SQL.


🔹 44. What is UNION?

Combines results of two queries.


🔹 45. Difference between UNION and UNION ALL?

UNIONUNION ALL
Removes duplicatesKeeps duplicates

🔹 46. What is EXISTS?

Checks if subquery returns results.


🔹 47. What is IN operator?

Checks multiple values.


🔹 48. What is BETWEEN?

Used for range condition.


🔹 49. What is LIKE operator?

Used for pattern matching.


🔹 50. Why SQL is important?

SQL is used in:

  • Web applications
  • Banking systems
  • E-commerce
  • Data analysis