ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

SQL Database Tutorial• 5 min read

SQL INSERT, UPDATE & DELETE

Modifying table data with safe transaction practices

CRUD operations (Create, Read, Update, Delete) are the foundation of database state management.

Modifying Records

INSERT INTO table (col1, col2) VALUES (val1, val2); inserts new records.

UPDATE table SET col1 = val1 WHERE id = 1; modifies existing data.

DELETE FROM table WHERE id = 1; removes records.

Safe UPDATE and INSERT statements
-- 1. Add new student
INSERT INTO Students (Name, Track, XP)
VALUES ('Jordan Taylor', 'Full Stack', 100);

-- 2. Update XP for a specific student
UPDATE Students
SET XP = XP + 50
WHERE Name = 'Jordan Taylor';
Warning / Pitfall

CRITICAL: Notice the WHERE clause in UPDATE and DELETE statements! If you omit the WHERE clause, ALL records in the table will be updated or deleted!

ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

What happens if you run "DELETE FROM Customers;" without a WHERE clause?