D
DevPrepSystematic Prep
DEVPREP CODEX · #24

SQL Interview Questions

171 curated questions graded from Foundations (Easy) to Practical Patterns (Medium) and Internals & Architecture (Hard).

TOTAL QUESTIONS

171

THEORY QUESTIONS

150

IMPLEMENTATION FOLIOS

21

FREE QUESTIONS

5 / Level

Easy Level·57 Questions Total

Foundations & Core Concepts

Open Full Easy List
Q1What is SQL and how does it differ from NoSQL?
  • SQL (Structured Query Language): Relational database management system (RDBMS) language. Uses structured schemas, tabular relations (tables/columns/rows), and enforces ACID properties.
  • NoSQL (Not Only SQL): Non-relational database system. Uses flexible schemas (document, key-value, wide-column, graph), scales horizontally, and prioritizes BASE properties (Basically Available, Soft state, Eventual consistency).
Q2Categorize standard SQL commands into their sub-languages. What are DDL, DML, TCL, and DCL?
  • DDL (Data Definition Language): Defines/modifies schema structures. Commands: CREATE, ALTER, DROP, TRUNCATE.
  • DML (Data Manipulation Language): Manipulates and queries data. Commands: SELECT, INSERT, UPDATE, DELETE.
  • TCL (Transaction Control Language): Manages database transactions. Commands: COMMIT, ROLLBACK, SAVEPOINT.
  • DCL (Data Control Language): Manages access permissions. Commands: GRANT, REVOKE.
Q3What is a Primary Key and how does it differ from a Unique Key?
  • Primary Key (PK): Uniquely identifies a record in a table. Does not allow NULLs. Only one PK allowed per table. Creates a clustered index by default.
  • Unique Key (UK): Ensures all values in a column are distinct. Allows NULL values (single or multiple depending on SQL dialect). Multiple UKs allowed per table. Creates a non-clustered index by default.
Q4What is a Foreign Key, and how does it maintain referential integrity?
  • Foreign Key (FK): A column or group of columns in one table that references the PK/UK of another table.
  • Referential Integrity: Ensures relationships between tables remain consistent. Prevents orphaned rows by restricting invalid inserts, and handles deletes/updates via rules like ON DELETE CASCADE or ON DELETE SET NULL.
Q5What are the different types of Joins in SQL?
  • INNER JOIN: Returns records with matching values in both tables.
  • LEFT (OUTER) JOIN: Returns all records from the left table, and matching records from the right; unmatched right side returns NULL.
  • RIGHT (OUTER) JOIN: Returns all records from the right table, and matching records from the left; unmatched left side returns NULL.
  • FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table; unmatched rows return NULL.
  • CROSS JOIN: Returns the Cartesian product of both tables (every combination of rows).
52 More Easy Questions Locked

Unlock the complete SQL Easy question bank

Get instant access to all 57 questions, in-depth model answers, code sandboxes, and all 27+ technologies for a single one-time payment.

Unlock All — One-time payment · Lifetime access
DEDICATED LEVEL PAGES

Browse All SQL Questions by Difficulty

INTERNAL LINKING & DEPENDENCIES

Related Technologies to SQL

CAREER PATHWAYS

SQL is a key requirement for these engineering roles:

SQL Interview Questions — Easy, Medium & Hard | DevPrep | DevPrep