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.
Learn SQL INSERT, UPDATE, and DELETE statements with simple, copy-pasteable examples. A beginner-friendly guide to adding, changing, and removing data.
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.
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).
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.
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:
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.
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.
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.
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.
DELETE removes entire rows from a table. Like UPDATE, it needs a WHERE clause to control which rows are removed.
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.
| Command | What it does | Needs WHERE? | Example use case |
|---|---|---|---|
| INSERT | Adds a new row | No | A new user signs up |
| UPDATE | Changes values in existing rows | Yes, almost always | A user changes their email |
| DELETE | Removes existing rows | Yes, almost always | A user closes their account |
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
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.
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 guideINSERT 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.
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.
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.
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.
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 teamOccasional, no-fluff notes on shipping modern software — startups, automation, Laravel, Shopify and more. No spam, unsubscribe anytime.
Keep reading
Learn SQL CASE WHEN step by step. This beginner guide shows how to label, group and sort data with simple examples you can copy and run today.
PostgreSQL ILIKE explained for beginners: search text without worrying about case, learn % and _ wildcards, and copy simple examples you can run today.
Let's build something
Book a free discovery call. We'll listen, ask sharp questions, and send you a proposal within 3 business days.