SQL and MySQL course Β· Module 5: Modifying data (DML)
The Scribe's Desk
In this lesson2
Welcome to the Scribe's Desk! Until now you have only learned to read scrolls - you gave the Library a SELECT command and received data back. But the Library is not a fossil. Every day new books arrive, prices change, new readers enroll, and some scrolls must be removed.
Here, at the Scribe's Desk, you will learn to change the contents of the shelves. In the Library's language we call this art DML - Data Manipulation Language, the language of modifying data.
The scribe's three great commands
A scribe wields three powerful commands:
- INSERT - write a new scroll onto a shelf (add a row).
- UPDATE - correct an existing scroll (change data in a row).
- DELETE - take a scroll off the shelf (remove a row).
These are not innocent spells like SELECT. SELECT only shows data - it breaks nothing. But INSERT, UPDATE and DELETE permanently change the Library's contents.
The great warning
Remember these words, for I will repeat them more than once: UPDATE and DELETE without WHERE act on the WHOLE shelf. One careless command can change the price of all books or wipe out all readers at once.
A good scribe always aims first (WHERE) and only then writes. In this location I will teach you this discipline. Let us sit down to work!
Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. What is DML (Data Manipulation Language)?
2. Which of the DML commands is used to ADD a new row to a table?