Lesson 7 / 28

INSERT

Add new rows into a table.

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's generally faster than one INSERT per row
  • It skips the NOT NULL constraints
Answer

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