SQL Tutorial
INSERT, UPDATE and DELETE
Create, modify and remove rows safely.
Concept
INSERT adds rows, UPDATE changes existing rows and DELETE removes rows. Always verify your WHERE condition before a destructive update or delete.
Transactions are valuable when several changes must succeed or fail together. For important data, preview affected rows with a SELECT before running a broad modification.
Example
INSERT INTO students (student_id, name, city)
VALUES (1, 'Riya', 'Jaipur');
UPDATE students
SET city = 'Ajmer'
WHERE student_id = 1;
Type the example yourself and change at least one value. Small experiments reveal syntax and behavior faster than passive reading.
Practice Tasks
- Insert three sample records.
- Update one record using its primary key.
- Write a delete statement that removes only one known test row.
Key Takeaways
- DML changes stored data.
- A missing WHERE can affect every row.
- Use transactions for grouped changes.
Previous
← SELECT, WHERE and ORDER BY
← SELECT, WHERE and ORDER BY
Next
SQL Joins →
SQL Joins →