Practice Flashcards
Flip to reveal answersWhat do INSERT, UPDATE and DELETE each do?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All 5 Flashcards — Updating data with SQL
Sign up free to track progress and get spaced-repetition review schedules.
Question
What do INSERT, UPDATE and DELETE each do?
Answer
INSERT INTO adds a new row; UPDATE SET changes values in rows that already exist; DELETE removes rows. All three are DML, so the table's structure is untouched.
Question
What happens if an UPDATE or DELETE has no WHERE clause?
Answer
It applies to every row in the table, with no warning, no confirmation and no undo once committed. The safe habit is to write the WHERE clause first and test it with a SELECT.
Question
Why does an index make reads fast and writes slow?
Answer
It is a separate sorted structure the database can go straight to, instead of reading every row. But every INSERT, UPDATE or DELETE on an indexed column must update that structure as well as the row.
Question
What is index fragmentation, and how is it fixed?
Answer
After many changes an index's entries no longer sit in an efficient order, so it gradually stops helping. Reorganising tidies it in place; rebuilding constructs it from scratch. Both are usually scheduled for quiet hours.
Question
Why might indexes be dropped before a bulk load and rebuilt afterwards?
Answer
With indexes present, every one of the millions of inserted rows updates every index individually. Building each index once at the end is a single sorted pass, which is far cheaper.
Read the notes
Full study notes for Updating data with SQL
Topic 3.3 hub
Database programming
More from Topic 3.3
All flashcards in this topic
Computer Science exam skills
Paper structures & tips
Track your progress with spaced repetition
Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.
Start Free