1.
DBMS & RDBMS
DBMS (Database Management System) stores data in files without any relation between them.
RDBMS (Relational DBMS) stores data in tables with relationships among them using keys.
2. Primary Key
A primary key uniquely identifies each record in a table. It cannot be NULL or duplicate.
3. Foreign Key
A foreign key is a field in one table that refers to the primary key in another table. It is used to
maintain referential integrity.
4. Constraints & their types
Constraints are rules applied to table columns. Types include: NOT NULL, UNIQUE, PRIMARY
KEY, FOREIGN KEY, CHECK, DEFAULT.
5. Different types of SQL commands
SQL commands are grouped as: DDL (CREATE, DROP), DML (INSERT, UPDATE), DCL (GRANT,
REVOKE), TCL (COMMIT, ROLLBACK), DQL (SELECT).
6. Difference between DELETE, DROP & TRUNCATE
DELETE removes selected rows (can be rolled back). TRUNCATE removes all rows (faster, can't be
rolled back). DROP deletes the entire table.
7. Difference between GROUP BY & ORDER BY
GROUP BY is used to group rows with the same values. ORDER BY sorts the result set by one or
more columns.
8. Types of Joins
INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN, SELF JOIN. They combine rows from two or
more tables based on a related column.
9. Nested subquery vs Correlated subquery
Nested: runs once and gives result to outer query. Correlated: runs for each row of outer query.
10. Pattern Matching
Uses LIKE operator with % (any number of chars) and _ (single char). Example: WHERE name
LIKE 'A%'.
11. Find 2nd or Nth highest salary
Use subquery: SELECT MAX(salary) FROM employee WHERE salary < (SELECT MAX(salary)
FROM employee);
12. SQL vs MySQL (NoSQL)
SQL is a language for relational databases. MySQL is a popular SQL-based database. NoSQL
handles unstructured data (e.g., MongoDB).
13. VARCHAR vs VARCHAR2
VARCHAR is ANSI standard; VARCHAR2 is Oracle-specific and more efficient. Both store
variable-length strings.
14. Triggers
A trigger is a stored procedure that runs automatically when certain events happen (INSERT,
UPDATE, DELETE).
15. ACID properties
ACID stands for Atomicity, Consistency, Isolation, Durability. These ensure reliable transactions in a
database.