Civil Service Hospital2080 BSQuestion 5 of 10
How does DML differ from DDL? Explain DML and DDL statements with example of each.
10 marks
Question source
- Exam year
- 2080 BS / 2023 AD
- Level
- Level 5 (Prabidhik, Engineering and Maintenance, Computer Technician)
- Paper
- Paper II – Technical Subject
- Section
- Section A
Model answer
Both are SQL sub-languages, but operate at different levels.
| Basis | DDL | DML |
|---|---|---|
| Purpose | Defines structure | Manipulates rows |
| Effect | Creates/alters tables | Inserts/updates/deletes data |
| Auto-commit | Yes, immediate | Depends on transaction (can rollback) |
DDL examples (structure):
CREATE TABLE Patient (ID INT PRIMARY KEY, Name VARCHAR(50));
ALTER TABLE Patient ADD Phone VARCHAR(15);
DROP TABLE OldRecords;
TRUNCATE TABLE Temp;
DML examples (data):
INSERT INTO Patient VALUES (1,'Sita','98...');
UPDATE Patient SET Phone='985...' WHERE ID=1;
DELETE FROM Patient WHERE ID=5;
SELECT Name FROM Patient WHERE District='Chitwan';
Exam line: DDL = builds the cupboard, DML = puts/removes files in it. Hospital DBA uses DDL once, DML daily.