Lesson 7 / 30

INSERT

Add rows with INSERT INTO, list columns explicitly and insert many rows in one statement.

By · 15 years in web development · Updated 1 Oct 2026

Inserting one row

List the columns, then matching values in the same order.

INSERT INTO customers (name, email)
VALUES ('Asha Rao', 'asha@example.com');

Output:

Query OK, 1 row affected

Inserting multiple rows

One INSERT statement can add several rows at once — faster than one statement per row.

INSERT INTO customers (name, email) VALUES
  ('Rahul Mehta', 'rahul@example.com'),
  ('Priya Nair', 'priya@example.com');

Output:

Query OK, 2 rows affected

Quick check: Why insert multiple rows in a single statement?

  • It's the only way MySQL allows inserts
  • It skips the NOT NULL constraints
  • It encrypts the inserted data
  • It's generally faster than one INSERT per row
Answer

It's generally faster than one INSERT per row — Batching reduces round trips to the server.