DBMS SQL – GATE & Rajasthan Competitive Exams Short Revision Notes
- SQL = Structured Query Language
- Standard language for Relational Database Management Systems (RDBMS).
- Used to Create, Read, Update, Delete (CRUD) data.
- SQL is a Declarative (Non-Procedural) language.
| Category | Commands | Purpose |
|---|---|---|
| DDL | CREATE, ALTER, DROP, TRUNCATE, RENAME | Defines database structure |
| DML | INSERT, UPDATE, DELETE | Manipulates data |
| DQL | SELECT | Retrieves data |
| DCL | GRANT, REVOKE | Controls permissions |
| TCL | COMMIT, ROLLBACK, SAVEPOINT | Controls transactions |
Exam Trick
- DDL → Structure
- DML → Data
- DQL → Query
- DCL → Control
- TCL → Transaction
Numeric
- INT
- BIGINT
- FLOAT
- DOUBLE
- DECIMAL
Character
- CHAR
- VARCHAR
Date & Time
- DATE
- TIME
- DATETIME
- TIMESTAMP
CREATE
Creates objects.
ALTER
Changes table structure.
DROP
Deletes table permanently.
TRUNCATE
Deletes all rows but keeps table structure.
RENAME
Changes table name.
INSERT
Adds records.
UPDATE
Modifies records.
DELETE
Deletes selected records.
Retrieve all records
Specific columns
Filters rows.
Cannot use aggregate functions.
Sorts output.
Ascending
Descending
Removes duplicate values.
| Symbol | Meaning |
|---|---|
| % | Multiple characters |
| _ | Single character |
Example
Inclusive operator.
Never use
| Function | Purpose |
|---|---|
| COUNT() | Count rows |
| SUM() | Total |
| AVG() | Average |
| MIN() | Minimum |
| MAX() | Maximum |
Remember
- COUNT(*) counts all rows.
- COUNT(column) ignores NULL values.
- AVG() ignores NULL values.
Groups rows.
Filters grouped records.
| WHERE | HAVING |
|---|---|
| Before GROUP BY | After GROUP BY |
| Row Filter | Group Filter |
| No Aggregate | Aggregate Allowed |
- PRIMARY KEY
- FOREIGN KEY
- UNIQUE
- NOT NULL
- CHECK
- DEFAULT
Primary Key
- Unique
- NOT NULL
Foreign Key
- Creates relationship
- Maintains Referential Integrity
Unique
- Unique values
- NULL allowed (DBMS dependent)
- INNER JOIN – Matching rows only.
- LEFT JOIN – All rows from left table.
- RIGHT JOIN – All rows from right table.
- FULL OUTER JOIN – All rows from both tables.
- CROSS JOIN – Cartesian Product
Rows = m × n - SELF JOIN – Table joins with itself.
Virtual table.
Purpose
- Faster searching
- Faster SELECT
Disadvantages
- Extra storage
- Slower INSERT
- Slower UPDATE
- Slower DELETE
Commands
- COMMIT
- ROLLBACK
- SAVEPOINT
| Property | Meaning |
|---|---|
| A | Atomicity |
| C | Consistency |
| I | Isolation |
| D | Durability |
- SQL is Declarative.
- SELECT belongs to DQL.
- CREATE belongs to DDL.
- INSERT belongs to DML.
- COMMIT belongs to TCL.
- GRANT belongs to DCL.
- PRIMARY KEY = UNIQUE + NOT NULL.
- FOREIGN KEY maintains Referential Integrity.
- HAVING works after GROUP BY.
- WHERE cannot use aggregate functions.
- COUNT(*) counts NULL rows.
- COUNT(column) ignores NULL.
- AVG ignores NULL.
- CROSS JOIN = Cartesian Product.
CRUD
- Create
- Read
- Update
- Delete
SQL Commands
- DDL → Define
- DML → Modify
- DQL → Query
- DCL → Control
- TCL → Transaction
ACID
- A → Atomicity
- C → Consistency
- I → Isolation
- D → Durability
- ✅ SQL = Structured Query Language
- ✅ SQL is Declarative.
- ✅ DDL is Auto Commit.
- ✅ DML can be Rolled Back.
- ✅ DELETE removes selected rows.
- ✅ TRUNCATE removes all rows only.
- ✅ DROP removes the complete table.
- ✅ PRIMARY KEY = UNIQUE + NOT NULL.
- ✅ FOREIGN KEY creates relationships.
- ✅ WHERE filters rows.
- ✅ HAVING filters groups.
- ✅ GROUP BY creates groups.
- ✅ DISTINCT removes duplicates.
- ✅ COUNT(*) counts every row.
- ✅ COUNT(column) ignores NULL.
- ✅ AVG() ignores NULL.
- ✅ INNER JOIN returns matching rows.
- ✅ LEFT JOIN returns all left rows.
- ✅ RIGHT JOIN returns all right rows.
- ✅ CROSS JOIN returns Cartesian Product.
- ✅ COMMIT saves transaction permanently.
- ✅ ROLLBACK undoes uncommitted changes.
- ✅ ACID = Atomicity, Consistency, Isolation, Durability.
DML → Data → Rollback Possible
WHERE → Rows
HAVING → Groups
COUNT(*) ≠ COUNT(column)
Primary Key ⊂ Candidate Key ⊂ Super Key
Foreign Key → Relationship
SQL Execution: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY
These are the highest-yield facts repeatedly tested in GATE CSE, UGC NET, RPSC Computer Teacher, Rajasthan Informatics Assistant, JVVNL, ISRO, BARC, and NIELIT examinations.
Practice MCQs (Exam-Oriented)
- 32–35 Correct: Excellent (GATE/RPSC Ready)
- 28–31 Correct: Very Good
- 22–27 Correct: Good Revision Needed
- Below 22: Revise SQL Basics Again
Exam Tip: Questions on DDL vs DML, WHERE vs HAVING, JOINs, Aggregate Functions, Constraints, ACID Properties, and SQL Execution Order are among the most frequently asked in GATE, RPSC Computer Teacher, Rajasthan Informatics Assistant, JVVNL, UGC NET, and other computer science competitive examinations.