DML: Insert, Update, and Delete
DML is the change-focused subset of database languages like SQL that adds, modifies, and removes data. It appears in every write to a table. The footgun is assuming SELECT belongs in DML; read-only querying is sometimes split out as DQL instead.
Why it exists
A data manipulation language exists because adding, deleting, and modifying data in a database is a distinct job from the broader language it lives inside. By isolating these operators into a sublanguage, programmers get a focused set of commands for routine data changes without clutter from other capabilities.
The mental model
Think of a database language like SQL as a full toolbox. DML is the specific set of tools that edits the contents already stored. While the broader language might contain other operators, DML is strictly the insert, update, and delete actions that change existing data rather than the surrounding structure.
How it works
A DML provides operators that target data already in a database. As a sublanguage of a broader database language such as SQL, the DML comprises some of the operators in the language, specifically those that insert, update, or delete. Read-only selecting of data is sometimes distinguished as being part of a separate data query language, but it is closely related and sometimes also considered a component of a DML. Some operators may perform both selecting and writing.
When to use it
Use DML whenever you need to change the actual contents of a database. That means adding new records, correcting existing values, or removing outdated entries. Any operation that alters stored data rather than the database language itself falls under this sublanguage.
When not to use it
Do not use DML when the task involves broader language concerns outside of inserting, updating, or deleting data. Also avoid assuming that read-only queries are automatically part of DML, because some systems classify selecting separately under DQL instead of grouping it with the writing operators.
One canonical example
In SQL, inserting a new row into an existing table is a textbook DML operation. Updating a column in that row or deleting it entirely are also DML actions. If you then run a command to retrieve the row, that read-only selection may or may not be considered DML depending on whether your environment treats it as part of DQL or includes it within DML.
Interview question
Which action is a clear use of DML because it changes stored data rather than table structure or read-only querying?
- a.Adding a new column to an existing table
- b.Running a SELECT statement to retrieve rows
- c.Creating a new table in the database
- d.Inserting a new row into an existing tableCorrect
Why? this is the answer
Inserting a new row is explicitly called a textbook DML operation that alters stored data. Running a SELECT statement is a tempting distractor because the card notes that read-only querying is sometimes classified separately as DQL rather than being grouped with DML.
Just read this? Test yourself on what you have been reading.
Read the original → en.wikipedia.org
- #dml
- #sql
- #databases
- #data-manipulation
- #dql
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles