🚀
4. DML Practice with customer_info
++++
Data Engineering
May 2026×8 min read

Practice insert, select, null checks, update, delete, and alter operations on a small customer_info table.

4. DML Practice with customer_info

Driptanil Datta
Driptanil DattaSoftware Developer

DML Practice with customer_info

Data Manipulation Language, or DML, is the part of SQL used to work with rows:

  • INSERT adds rows.
  • SELECT reads rows.
  • UPDATE changes rows.
  • DELETE removes rows.

This practice uses the existing companydb database from the previous lesson.

Create the table

USE companydb;
 
CREATE TABLE customer_info (
  id INT AUTO_INCREMENT PRIMARY KEY,
  first_name VARCHAR(25),
  last_name VARCHAR(25),
  salary INT
);

AUTO_INCREMENT lets MySQL generate the next id value for each inserted row.

Insert rows

Insert one customer:

INSERT INTO customer_info (first_name, last_name, salary)
VALUES
  ("Krish", "Naik", 50000);

Insert multiple customers:

INSERT INTO customer_info (first_name, last_name, salary)
VALUES
  ("Darius", "N", 50000),
  ("Mahendra", "B", 50000),
  ("Ankit", "Sharma", NULL);

Check the table:

SELECT *
FROM customer_info;

Find missing and present salaries

Find customers whose salary is missing:

SELECT first_name, last_name
FROM customer_info
WHERE salary IS NULL;
 
SELECT *
FROM customer_info
WHERE salary IS NULL;

Find customers whose salary is present:

SELECT first_name, last_name
FROM customer_info
WHERE salary IS NOT NULL;
 
SELECT *
FROM customer_info
WHERE salary IS NOT NULL;

Replace a NULL value

Update the customer whose generated ID is 4.

UPDATE customer_info
SET salary = 60000
WHERE id = 4;

Delete a row

DELETE FROM customer_info
WHERE id = 3;

Then inspect the remaining data:

SELECT *
FROM customer_info;

Insert another row correctly

The original practice script had a mismatched insert: it listed three target columns but supplied four values. Because id is auto-generated, the clean version is:

INSERT INTO customer_info (first_name, last_name, salary)
VALUES
  ("Darius", "N", 50000);

If you want to set the ID yourself, include the id column and choose an unused value.

INSERT INTO customer_info (id, first_name, last_name, salary)
VALUES
  (10, "Darius", "N", 50000);

Alter the table

Add one column:

ALTER TABLE customer_info
ADD COLUMN dob DATE;

Add multiple columns:

ALTER TABLE customer_info
ADD COLUMN email VARCHAR(25),
ADD COLUMN address VARCHAR(25);

Inspect the schema:

DESC customer_info;

Modify the column size:

ALTER TABLE customer_info
MODIFY COLUMN address VARCHAR(30);

Drop a column:

ALTER TABLE customer_info
DROP COLUMN email;

This exercise is small, but it covers the core row-level operations used in real data cleanup work.

Drip

Driptanil Datta

Software Developer

Building full-stack systems, one commit at a time. This blog is a centralized learning archive for developers.

Legal Notes
Disclaimer

The content provided on this blog is for educational and informational purposes only. While I strive for accuracy, all information is provided "as is" without any warranties of completeness, reliability, or accuracy. Any action you take upon the information found on this website is strictly at your own risk.

Copyright & IP

Certain technical content, interview questions, and datasets are curated from external educational sources to provide a centralized learning resource. Respect for original authorship is maintained; no copyright infringement is intended. All trademarks, logos, and brand names are the property of their respective owners.

System Operational

© 2026 Driptanil Datta. All rights reserved.