Skip to main content

Data Manipulation Language (DML) ๐Ÿš€

Mentor's Note: If DDL is building the house, DML is moving the furniture in, changing the sofa, or throwing out old trash. It's how you manage the actual Information! ๐Ÿ’ก


๐ŸŒŸ The Scenario: The Warehouse Manager ๐Ÿ“ฆโ€‹

Imagine you manage a grocery warehouse.

  • INSERT: A truck arrives with 50 crates of Apples ๐ŸŽ. You add them to your inventory record.
  • UPDATE: The price of Milk ๐Ÿฅ› goes up. You change the label on the shelf.
  • DELETE: A box of Bananas ๐ŸŒ is rotten. You remove it from the records.
  • The Result: Your inventory stays current and accurate. โœ…

๐Ÿ“– Key DML Commandsโ€‹

1. INSERTโ€‹

Used to add new rows to a table.

INSERT INTO students (id, name, age)
VALUES (101, 'Vishnu', 25);

2. UPDATEโ€‹

Used to modify existing records. Always use a WHERE clause or you will update every row! โš ๏ธ

UPDATE students
SET age = 26
WHERE id = 101;

3. DELETEโ€‹

Used to remove specific rows.

DELETE FROM students
WHERE id = 101;

๐ŸŽจ Visual Logic: The DML Impactโ€‹


๐Ÿ’ป Implementation: The Inventory Labโ€‹

-- ๐Ÿ›’ Scenario: Stocking a new product
-- ๐Ÿš€ Action: Inserting a laptop record

INSERT INTO products (pid, pname, stock)
VALUES (5001, 'Dell XPS', 10);

-- ๐Ÿ›๏ธ Outcome: A new row appears in the table.

๐Ÿ“Š Sample Dry Run (DELETE)โ€‹

Command: DELETE FROM users WHERE status = 'Inactive'

IDNameStatusAction
1VishnuActiveKEEP โœ…
2JohnInactiveDELETE ๐Ÿ—‘๏ธ
3SaraActiveKEEP โœ…

๐Ÿ“ˆ Technical Analysisโ€‹

  • Transaction Control: In Oracle, DML changes are not permanent until you run the COMMIT command. If you make a mistake, you can undo it using ROLLBACK. ๐Ÿ›ก๏ธ

๐ŸŽฏ Practice Lab ๐Ÿงชโ€‹

Task: Update the Grades

Task: You have a GRADES table. Student 105 was given B by mistake. Change it to A. Then, delete all records where the student has Left the school. Hint: Use UPDATE and DELETE with specific WHERE clauses. ๐Ÿ’ก


๐Ÿ’ก Interview Tip ๐Ÿ‘”โ€‹

"Interviewers love the 'Where Clause' question. What happens if you run UPDATE employees SET salary = 90000 without a WHERE clause? Answer: Everyone in the company gets the same salary! ๐Ÿ˜ฑ Always double-check your WHERE clause."


๐Ÿ’ก Pro Tip: "The only thing constant is change." - Heraclitus


โ† Back: DDL | Next: PL/SQL Foundations โ†’

๐Ÿ“ Visit Us

๐Ÿซ VD Computer Tuition Surat

VD Computer Tuition
๐Ÿ“ Address
2/66 Faram Street, Rustompura
Surat โ€“ 395002, Gujarat, India
๐Ÿ“ž Phone / WhatsApp
+91 84604 41384
๐ŸŒ Website

Computer Classes & Tuition โ€” Areas We Serve in Surat

Adajanโ€ขAlthanโ€ขAmroliโ€ขAthwaโ€ขAthwalinesโ€ขBhagalโ€ขBhatarโ€ขBhestanโ€ขCanal Roadโ€ขChowkโ€ขCitylightโ€ขDumasโ€ขGaurav Pathโ€ขGhod Dod Roadโ€ขHaziraโ€ขJahangirpuraโ€ขKamrejโ€ขKapodraโ€ขKatargamโ€ขLimbayatโ€ขMagdallaโ€ขMajura Gateโ€ขMota Varachhaโ€ขNanpuraโ€ขNew Citylightโ€ขOlpadโ€ขPalโ€ขPandesaraโ€ขParle Pointโ€ขPiplodโ€ขPunaโ€ขRanderโ€ขRing Roadโ€ขRustampuraโ€ขSachinโ€ขSalabatpuraโ€ขSarthanaโ€ขSosyo Circleโ€ขUdhnaโ€ขVarachhaโ€ขVed Roadโ€ขVesuโ€ขVIP Road
๐Ÿ“ž Call Sir๐Ÿ’ฌ WhatsApp Sir