What if you could update thousands of records instantly without flipping through pages or risking mistakes?
Why DML (INSERT, UPDATE, DELETE) in DBMS Theory? - Purpose & Use Cases
Imagine you have a huge paper ledger where you write down every sale in your store by hand. When a new sale happens, you have to find the right page and add it. If a customer changes their order, you must erase and rewrite it. If a sale is canceled, you have to cross it out carefully. This takes a lot of time and can get messy quickly.
Doing all these changes by hand is slow and mistakes happen easily. You might write wrong numbers, lose track of updates, or accidentally erase important information. It's hard to keep everything accurate and up to date, especially as the number of sales grows.
DML commands like INSERT, UPDATE, and DELETE let you tell the database exactly what to add, change, or remove. This makes managing data fast, clear, and reliable. You don't have to rewrite everything; you just give simple instructions and the database handles the rest.
Write each sale on paper, erase and rewrite for changes, cross out canceled sales.
INSERT INTO sales VALUES (...); UPDATE sales SET ... WHERE ...; DELETE FROM sales WHERE ...;
It enables quick and accurate management of data, making large and complex information easy to handle.
A store owner can quickly add new sales, update customer details, or remove canceled orders from their database without confusion or delay.
DML commands simplify adding, changing, and removing data.
They prevent errors and save time compared to manual record keeping.
They make managing large amounts of data practical and efficient.
Practice
Solution
Step 1: Understand the purpose of DML commands
DML commands are used to manipulate data in tables: adding, changing, or removing rows.Step 2: Identify the command for adding rows
TheINSERTcommand adds new rows,UPDATEchanges existing rows, andDELETEremoves rows.Final Answer:
INSERT -> Option AQuick Check:
Add new rows = INSERT [OK]
- Confusing UPDATE with INSERT
- Using DELETE to add data
- Thinking SELECT adds data
Solution
Step 1: Recall the UPDATE syntax
The correct syntax isUPDATE table_name SET column = value WHERE condition;to update specific rows.Step 2: Check each option
UPDATE employees SET salary = 5000 WHERE id = 10; matches the correct syntax with a WHERE clause to target employee id 10. Options B and C miss the SET keyword or equal sign. UPDATE employees SET salary = 5000; lacks WHERE, so it updates all rows.Final Answer:
UPDATE employees SET salary = 5000 WHERE id = 10; -> Option CQuick Check:
UPDATE with SET and WHERE = UPDATE employees SET salary = 5000 WHERE id = 10; [OK]
- Omitting SET keyword
- Missing WHERE clause
- Wrong assignment syntax
products with columns id, name, and price. What will be the result of this query?DELETE FROM products WHERE price < 100;
Solution
Step 1: Understand DELETE with WHERE condition
The DELETE command removes rows matching the WHERE condition. Here, it targets rows where price is less than 100.Step 2: Analyze the condition and syntax
The conditionprice < 100correctly selects products priced below 100. The semicolon is optional in many systems but good practice.Final Answer:
All products with price less than 100 will be removed. -> Option BQuick Check:
DELETE with price < 100 removes matching rows [OK]
- Confusing less than with greater than
- Thinking DELETE needs all rows
- Assuming syntax error without semicolon
UPDATE employees SET salary = 6000 WHERE;
Solution
Step 1: Check the UPDATE statement structure
UPDATE requires SET to assign new values and WHERE to specify which rows to update.Step 2: Identify the error in the WHERE clause
The statement ends with WHERE but no condition follows, which is a syntax error.Final Answer:
Missing condition after WHERE clause. -> Option AQuick Check:
WHERE must have a condition [OK]
- Leaving WHERE empty
- Putting value in quotes unnecessarily
- Confusing UPDATE with DELETE
Solution
Step 1: Understand the requirement to increase price by 10%
Increasing by 10% means multiplying the current price by 1.10 (100% + 10%).Step 2: Analyze each option
UPDATE products SET price = price * 1.10 WHERE price < 50; correctly multiplies price by 1.10 for prices less than 50. UPDATE products SET price = price + 10 WHERE price < 50; adds 10 units, not 10%. UPDATE products SET price = price * 0.10 WHERE price < 50; multiplies by 0.10, reducing price. UPDATE products SET price = price + 0.10 WHERE price < 50; adds 0.10 units, a small increase.Final Answer:
UPDATE products SET price = price * 1.10 WHERE price < 50; -> Option DQuick Check:
Multiply price by 1.10 to increase by 10% [OK]
- Adding fixed amount instead of percentage
- Multiplying by 0.10 reduces price
- Forgetting WHERE clause
Ready to prove it?
Pass the test and this pattern moves unknown
