Back to Topic 3.3 — Database programming
3.3.3Computer Science SL5 flashcards

Updating data with SQL

Practice Flashcards

Flip to reveal answers
Card 1 of 53.3.3
3.3.3
Question

What do INSERT, UPDATE and DELETE each do?

Click to reveal answer

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.

Card 1definition

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.

Card 2concept

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.

Card 3concept

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.

Card 4concept

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.

Card 5example

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.

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