SQL Data Manipulation (DML)
SQL Data Manipulation Language (DML) gives you a way to handle data and offer modifications of the data you have in database tables. SQL induces records being created with Data Definition Language (DDL) commands, but DML affects the table data by inserting, updating, deleting, or selecting the data.
Data Manipulation (DML) is used daily in real world applications to handle user data, transactions, and business records efficiently. It is not essential to use DML commands, but they are important as they allow you to get at real data inside a database.
Main DML Commands in SQL
There are four main DML commands:
- INSERT
- SELECT
- UPDATE
- DELETE
Let‘s get to know about each of them with simple examples.
1. INSERT Command
This command is used to insert a new data or add new records in a table.
Example:
INSERT INTO users (id, name, email)
VALUES (1, 'Rahul', 'rahul@gmail.com');
This query inserts a new user into the users table.
2. SELECT Command
The SELECT command fetch data from a table.
Example:
SELECT * FROM users;
This query will return all records from the users table.
Specific data accessed via using where clause:
SELECT name FROM users
WHERE id = 1;
3. UPDATE Command
The UPDATE command modifies existing data.
Example:
UPDATE users
SET email = 'rahul123@gmail.com'
WHERE id = 1;
This updates the email of the user that have id 1.
Always use a WHERE clause to prevent updating everything.
4. DELETE Command
We use DELETE command to delete records from a table.
Example:
DELETE FROM users
WHERE id = 1;
Removes the user with id 1.
Be careful using DELETE. DML, you do not include a WHERE condition, all records will be deleted.
Why SQL DML Is Important
Once you are comfortable with structure, you will want to use DML commands to manipulate real data in your application. Building a web site, maintaining employees records, or inputting orders in an e commerce system can use SQL Data Manipulation commands to administer data.
Check out our resources!
- Bootstrap Templates: Explore our Bootstrap Projects section.
- Free E-Books: Download your Free E-Books here.


