Modifying Data: INSERT, UPDATE, DELETE
So far every example has only read data. These three statements change it.
INSERT INTO students (name, xp)
VALUES ('Grace', 0);
UPDATE students
SET xp = xp + 25
WHERE name = 'Grace';
DELETE FROM students
WHERE xp = 0 AND name = 'Inactive User';
INSERT INTO table (columns) VALUES (...)adds a new row.UPDATE table SET column = value WHERE ...modifies existing rows that match the condition.DELETE FROM table WHERE ...removes matching rows.
WARNING
UPDATE and DELETE without a WHERE clause apply to every row in the table. Forgetting the WHERE is one of the most common, and most costly, mistakes in SQL, always double-check it before running either statement.