CRUD with SQLCore· 25 min read

INSERT — Adding Data

Add new rows to a table with the SQL INSERT statement — the “C” in CRUD. Learn the syntax and how to insert one row or many at once.

What you will learn

  • Insert one and many rows

Adding rows with INSERT

A new table is empty. To put data in, you use INSERT INTO — the C (Create) in CRUD. You tell MySQL which table, which columns you are filling, and the values to put in them. The order of the values must match the order of the columns you listed.

An INSERT works in three simple steps:

  1. Name the table and the columns you want to fill: INSERT INTO users (name, email, age).
  2. Provide the matching values in the same order with VALUES ('Asha', 'asha@x.com', 22).
  3. MySQL adds a new row and fills in any columns you left out (like id and created_at) automatically.
Insert one row, then several
INSERT INTO users (name, email, age)
VALUES ('Asha', 'asha@x.com', 22);

INSERT INTO users (name, email, age) VALUES
  ('Ravi', 'ravi@x.com', 25),
  ('Meera', 'meera@x.com', 23);

The first statement adds a single row for Asha. The second adds two rows in one go — notice you only write VALUES once, then list each row in its own brackets separated by commas. Inserting many rows at once like this is faster than running a separate INSERT for each. The text values (name, email) sit in single quotes; the number (age) does not.

Note: Output: Query OK, 1 row affected. Query OK, 2 rows affected. MySQL confirms how many rows it added. The id column fills in automatically (AUTO_INCREMENT gives Asha 1, Ravi 2, Meera 3) and created_at fills in with the current time (its DEFAULT) — that is why you do not list them.

Q. Which SQL command adds new rows to a table?

Answer: INSERT INTO table (columns) VALUES (...) adds new rows.

✍️ Practice

  1. Insert three users into your table.
  2. Insert several products in one statement.

🏠 Homework

  1. Populate your library tables with sample data.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →