📢
Admissions Open for August 2026 Batch | Free Career Counselling | Limited Scholarships
Register Now →

Learning Guides

Data Manipulation Language (DML) in SQL: INSERT, UPDATE, DELETE Explained

Quick answer: Learn SQL Data Manipulation Language commands including INSERT, UPDATE, DELETE and SELECT, with syntax, examples, and how DML differs from DDL.

What is Data Manipulation Language?

DML is the subset of SQL commands used to work with the actual data stored inside database tables, rather than the structure of the tables themselves. The main DML commands are SELECT, INSERT, UPDATE and DELETE.

INSERT: Adding New Rows

INSERT INTO students (student_id, name, email)
VALUES (101, 'Priya Sharma', 'priya@example.com');

-- Inserting multiple rows at once
INSERT INTO students (student_id, name, email)
VALUES
    (102, 'Aman Verma', 'aman@example.com'),
    (103, 'Neha Gupta', 'neha@example.com');

UPDATE: Modifying Existing Rows

UPDATE students
SET email = 'priya.sharma@example.com'
WHERE student_id = 101;

The WHERE clause is critical here. Without it, UPDATE modifies every single row in the table, which is one of the most common and damaging SQL mistakes.

-- DANGEROUS: updates EVERY row, since there is no WHERE clause
UPDATE students
SET email = 'default@example.com';

DELETE: Removing Rows

DELETE FROM students
WHERE student_id = 103;

Like UPDATE, omitting WHERE deletes every row in the table. Always double-check a WHERE clause, ideally by running the equivalent SELECT first to confirm which rows will be affected.

-- Safe practice: check first with SELECT
SELECT * FROM students WHERE student_id = 103;

-- Then delete once you've confirmed it's the right row
DELETE FROM students WHERE student_id = 103;

SELECT: Retrieving Data

SELECT is technically also classified as DML, since it works with data rather than structure, even though it does not modify anything.

SELECT name, email FROM students WHERE student_id = 101;

DML vs DDL

DMLDDL
Works with data (rows)Works with structure (tables, columns)
SELECT, INSERT, UPDATE, DELETECREATE, ALTER, DROP, TRUNCATE
Usually can be rolled back within a transactionOften auto-commits immediately in many databases

DML and Transactions

DML statements are typically used within transactions, allowing multiple changes to be committed together or rolled back entirely if something goes wrong.

BEGIN TRANSACTION;

UPDATE accounts SET balance = balance - 500 WHERE account_id = 1;
UPDATE accounts SET balance = balance + 500 WHERE account_id = 2;

COMMIT;   -- or ROLLBACK; if either step failed

Common Interview Questions

What is the difference between DML and DDL?

DML works with the actual data inside tables, such as inserting or updating rows. DDL works with the structure of database objects, such as creating or altering a table.

Why is it dangerous to run UPDATE or DELETE without a WHERE clause?

Without WHERE, the statement applies to every single row in the table, which can silently overwrite or destroy an entire table's data in production.

FAQ

Frequently Asked Questions

What is Data Manipulation Language in SQL?

DML is the set of SQL commands used to work with the actual data stored in tables, including SELECT, INSERT, UPDATE and DELETE.

What is the difference between DML and DDL?

DML works with the data inside tables, such as inserting or updating rows. DDL works with the structure of tables and other database objects, such as creating or dropping them.

Why should you always include a WHERE clause with UPDATE or DELETE?

Without a WHERE clause, the statement applies to every row in the table, which can unintentionally overwrite or delete an entire table's data.

Is SELECT considered a DML command?

Yes, technically, since it works with data rather than structure, even though it does not modify anything.

Want This Mapped to Your Own Background?

A free counselling session will tell you which path fits, and will tell you honestly if none of ours does.

Book Free Career Counselling

Keep Reading

Related Articles