All posts
SQLSeptember 18, 20268 min read

SQL INSERT, UPDATE, DELETE Explained for Beginners

Learn SQL INSERT, UPDATE, and DELETE statements with simple, copy-pasteable examples. A beginner-friendly guide to adding, changing, and removing data.

F
Fepiq Team
Fepiq

SQL INSERT, UPDATE, and DELETE are the three commands you use to change data in a database table. INSERT adds new rows, UPDATE changes values in existing rows, and DELETE removes rows you no longer need. Together with SELECT, they are the four basic operations every beginner needs to know before doing anything else in SQL. This guide walks through each one with small, copy-pasteable examples and explains every line in plain English.

Before You Start: What You Need

This guide assumes you already know how to look at data with SELECT and WHERE. If those two words are new to you, read our guide on SQL SELECT and WHERE for beginners first, then come back here. You do not need any special software to follow along — the examples below work in MySQL, PostgreSQL, SQLite, and SQL Server with only tiny differences.

All the examples use one imaginary table called users, with three columns: id (a number that uniquely identifies each row), name (a person's name), and email (their email address).

The INSERT Statement: Adding New Data

INSERT adds a brand new row to a table. Think of a table as a spreadsheet — INSERT adds one new line at the bottom with the values you give it.

sql
INSERT INTO users (name, email)
VALUES ('Maria Santos', 'maria@example.com');

Here is what each part does. INSERT INTO users tells the database which table gets the new row. (name, email) in parentheses lists which columns you are filling in — you can skip a column, like id, if the database fills it in automatically. VALUES ('Maria Santos', 'maria@example.com') gives the actual data, in the same order as the column list. Text values go inside single quotes; numbers do not need quotes. The semicolon at the end simply marks where the statement finishes.

You can insert more than one row at once by separating each set of values with a comma:

sql
INSERT INTO users (name, email)
VALUES
  ('Liam Chen', 'liam@example.com'),
  ('Aisha Bello', 'aisha@example.com');

This single statement adds two rows in one go, which is faster than writing two separate INSERT statements. Each pair of parentheses is one new row, matched to the (name, email) columns listed above.

The UPDATE Statement: Changing Existing Data

UPDATE changes the value of one or more columns in rows that already exist. You tell it which table, which column to change, what the new value should be, and — very importantly — which rows to change.

sql
UPDATE users
SET email = 'maria.santos@example.com'
WHERE id = 1;

UPDATE users says which table you are changing. SET email = 'maria.santos@example.com' says which column to change and its new value; separate multiple columns with commas, like SET email = '...', name = '...'. WHERE id = 1 says which row this applies to — in this case, only the row where id equals 1.

“Never run UPDATE without a WHERE clause unless you truly mean to change every single row in the table. Without WHERE, the new value is applied to every row at once.”

Before running an UPDATE on a real database, it is good practice to first run a SELECT with the same WHERE condition. That shows you exactly which rows will be affected before you change anything.

sql
SELECT * FROM users WHERE id = 1;

This returns the row you are about to update, so you can check it is the right one before running the UPDATE statement above.

The DELETE Statement: Removing Data

DELETE removes entire rows from a table. Like UPDATE, it needs a WHERE clause to control which rows are removed.

sql
DELETE FROM users
WHERE id = 2;

DELETE FROM users tells the database which table to remove rows from. WHERE id = 2 limits the deletion to only the row where id equals 2. If you leave out the WHERE clause, DELETE FROM users would remove every row in the table, leaving it empty.

DELETE removes rows, but it does not remove the table itself — the columns and the empty table are still there afterward, ready for new rows.

INSERT vs. UPDATE vs. DELETE: Quick Comparison

CommandWhat it doesNeeds WHERE?Example use case
INSERTAdds a new rowNoA new user signs up
UPDATEChanges values in existing rowsYes, almost alwaysA user changes their email
DELETERemoves existing rowsYes, almost alwaysA user closes their account

Practice Example: Managing a Tasks Table

Let's put all three commands together on a simple to-do list table called tasks, with columns id, title, and done (true or false).

  1. Add a new task with INSERT.
  2. Mark the task as finished with UPDATE.
  3. Remove the task once you no longer need it with DELETE.
sql
-- 1. Add a new task
INSERT INTO tasks (title, done)
VALUES ('Write blog post', false);

-- 2. Mark it as finished
UPDATE tasks
SET done = true
WHERE title = 'Write blog post';

-- 3. Delete it once it is no longer needed
DELETE FROM tasks
WHERE title = 'Write blog post';

Lines starting with -- are comments; SQL ignores them, and they are there to explain each step to a human reader. Notice each UPDATE and DELETE uses WHERE title = 'Write blog post' to target the exact row, instead of accidentally affecting every task in the table.

Common Mistakes Beginners Make

  • Forgetting the WHERE clause on UPDATE or DELETE, which changes or removes every row in the table.
  • Mixing up the order of columns and values in INSERT — the values must line up with the column list in the same order.
  • Forgetting quotes around text values, like 'Maria Santos', while leaving numbers unquoted.
  • Running DELETE or UPDATE directly on production data without first checking the affected rows with a matching SELECT.
  • Forgetting the semicolon at the end of a statement when running multiple statements together.

Not sure how WHERE conditions work yet? Start with the basics of filtering data before writing UPDATE or DELETE statements.

Read the SQL SELECT and WHERE guide

Frequently asked questions

What is the difference between SQL INSERT, UPDATE, and DELETE?+

INSERT adds a brand new row to a table, UPDATE changes values in rows that already exist, and DELETE removes rows entirely. INSERT never needs a WHERE clause because it always creates something new, while UPDATE and DELETE almost always need one to target the right rows.

What happens if I run UPDATE or DELETE without a WHERE clause?+

The command applies to every row in the table. UPDATE without WHERE changes the same column in all rows, and DELETE without WHERE removes every row, leaving an empty table. Always double-check your WHERE clause before running either command.

Can I undo a DELETE or UPDATE statement in SQL?+

Not by default. Once a DELETE or UPDATE is committed, the old data is gone unless you have a backup or are working inside a transaction you have not yet committed. Many beginners practice on a copy of their database, or wrap changes in a transaction using BEGIN and ROLLBACK, until they are confident.

Do I need to know SELECT before learning INSERT, UPDATE, and DELETE?+

It helps a lot. SELECT lets you check which rows a WHERE clause will match before you run UPDATE or DELETE, which prevents accidental changes to the wrong data. We recommend learning SELECT and WHERE first.

Is SQL the same in MySQL, PostgreSQL, and SQL Server?+

The INSERT, UPDATE, and DELETE syntax shown here works in all major databases with little to no change, since it is part of standard SQL. Small differences appear in more advanced features, like auto-incrementing IDs or date functions, but the basics you just learned are universal.

You now know how to add, change, and remove data with SQL. The safest habit to build from day one is simple: write your WHERE clause first, test it with a SELECT, and only then turn that SELECT into an UPDATE or DELETE.

Want help building an application backed by a real, well-structured database?

Talk to the Fepiq team

Get new posts in your inbox

Occasional, no-fluff notes on shipping modern software — startups, automation, Laravel, Shopify and more. No spam, unsubscribe anytime.

Keep reading

Related posts

All posts

Let's build something

Ready to ship your next product with Fepiq?

Book a free discovery call. We'll listen, ask sharp questions, and send you a proposal within 3 business days.