🔹 Top 100 SQL Interview Questions
1. SQL Basics (1–20)
-
What is SQL? Difference between SQL and PL/SQL.
-
Different types of SQL statements (DDL, DML, DCL, TCL).
-
Difference between Primary Key, Foreign Key, Unique Key.
-
What is a Constraint? Types of constraints.
-
Difference between TRUNCATE, DELETE, DROP.
-
What is a Schema in SQL?
-
What are Views? Types (Simple, Complex, Materialized).
-
Difference between View and Materialized View.
-
Difference between Cluster and Non-Clustered Index. -
What is a Stored Procedure? Advantages.
-
Difference between Procedure and Function.
-
What are Cursors? Types of Cursors.
-
Difference between Strongly Typed and Weakly Typed Cursor.
-
What are Sequences? How are they used?
-
Difference between CHAR and VARCHAR2.
-
What is a Synonym in SQL?
-
What is Normalization? Types (1NF to 5NF).
-
Difference between Normalization and Denormalization.
-
What is a Check Constraint?
-
Difference between Relational Database and Non-Relational Database.
2. Joins & Queries (21–40)
-
Different types of Joins.
-
Self Join example.
-
Cross Join vs Cartesian Product.
-
Equi Join vs Non-Equi Join.
-
Write query: Second highest salary.
-
Query: Nth highest salary (ROW_NUMBER vs Correlated Subquery).
-
Query: Find duplicate rows.
-
Query: Find employees joined in last 6 months.
-
Query: Display department-wise highest salary.
-
Query: Find employees without managers.
-
Query: Retrieve common records between two tables.
-
Query: Retrieve employees not present in another table.
-
Query: Display 5th to 10th highest salaries.
-
Query: Display manager → employee hierarchy (connect by / recursive CTE).
-
Query: Display employees earning more than their manager.
-
Query: Display top 3 salaries per department.
-
Query: Transpose rows to columns (Pivot).
-
Query: Transpose columns to rows (Unpivot).
-
Query: Find missing numbers in a sequence.
-
Query: Display employees with same salary.
3. Functions & Expressions (41–60)
-
NVL vs NVL2 vs COALESCE vs NULLIF.
-
Difference between Aggregate vs Analytic functions.
-
Explain RANK vs DENSE_RANK vs ROW_NUMBER.
-
Explain LAG and LEAD functions.
-
Explain FIRST_VALUE and LAST_VALUE.
-
Difference between IN and EXISTS.
-
Difference between ANY and ALL.
-
Difference between UNION and UNION ALL.
-
Difference between INTERSECT and MINUS.
-
What is CASE expression? Example.
-
Difference between DECODE and CASE.
-
Explain GROUPING SETS, ROLLUP, CUBE.
-
What is a Function-Based Index? Example.
-
Difference between Deterministic and Non-Deterministic function.
-
What is SYS_CONNECT_BY_PATH?
-
What is LISTAGG function?
-
Difference between COUNT(*), COUNT(1), COUNT(column).
-
Difference between CURRENT_DATE, SYSDATE, SYSTIMESTAMP.
-
Difference between DATE, TIMESTAMP, INTERVAL.
-
Difference between CHAR, VARCHAR2, NCHAR, NVARCHAR2.
4. Indexing & Performance (61–80)
-
What are different index types? (B-Tree, Bitmap, Reverse Key, Function-Based).
-
Difference between B-Tree vs Bitmap index.
-
What is Index Selectivity?
-
What is a Composite Index?
-
What is a Unique Index?
-
What is a Reverse Key Index?
-
When should you use a Bitmap Index?
-
How to detect full table scans unnecessarily?
-
How to check query execution plan? (EXPLAIN PLAN).
-
Difference between Cost-Based Optimizer and Rule-Based Optimizer.
-
Nested Loops Join vs Merge Join vs Hash Join.
-
How to tune a slow-running SQL query? Steps.
-
How to identify Top SQL queries consuming most resources?
-
Difference between Hard Parse and Soft Parse.
-
What are Bind Variables? Why important?
-
What are SQL Hints? Examples (INDEX, PARALLEL, FIRST_ROWS).
-
Difference between Global and Local Index.
-
What is Partitioning? Types (Range, List, Hash, Composite).
-
Partition Pruning in Oracle — how it works?
-
Star Schema vs Snowflake Schema.
5. Transactions & Concurrency (81–90)
-
What is ACID property?
-
Difference between COMMIT, ROLLBACK, SAVEPOINT.
-
What is Transaction Control Language (TCL)?
-
What is a Deadlock? How to detect and resolve?
-
What is a Lock? Types of locks.
-
Difference between Row-level vs Table-level lock.
-
What are Isolation Levels? Examples.
-
Explain Dirty Read, Non-Repeatable Read, Phantom Read.
-
Difference between Optimistic and Pessimistic Locking.
-
What is MVCC (Multi-Version Concurrency Control)?
6. Advanced SQL & Real Scenarios (91–100)
-
What is a Common Table Expression (CTE)? Recursive CTE example.
-
Difference between Global Temporary Table and Local Temporary Table.
-
Difference between Inline View and Subquery Factoring (WITH clause).
-
What is Materialized View Refresh? Types (Complete, Fast, Force).
-
Difference between OLTP and OLAP queries.
-
What is Sharding in databases?
-
Difference between Star Schema and Snowflake Schema in Data Warehousing.
-
How to implement Slowly Changing Dimensions (SCD) in SQL?
-
Explain ETL Testing SQL queries (Source vs Target count check).
-
Real-time scenario: How do you migrate millions of records with minimum downtime?
No comments:
Post a Comment