Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views2 pages

SQL Questions and Answers

The document outlines key concepts in database management, distinguishing between DBMS and RDBMS, and defining primary and foreign keys. It explains SQL commands, differences between DELETE, DROP, and TRUNCATE, and various types of joins and subqueries. Additionally, it covers pattern matching, ACID properties, and the differences between SQL and NoSQL databases.

Uploaded by

algo47177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

SQL Questions and Answers

The document outlines key concepts in database management, distinguishing between DBMS and RDBMS, and defining primary and foreign keys. It explains SQL commands, differences between DELETE, DROP, and TRUNCATE, and various types of joins and subqueries. Additionally, it covers pattern matching, ACID properties, and the differences between SQL and NoSQL databases.

Uploaded by

algo47177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

You might also like