While SELECT queries retrieve data, real database systems must also be able to change data. In IB Computer Science, this is done using three core SQL commands: INSERT, UPDATE, and DELETE. These commands allow databases to stay accurate, current, and useful.
IB examiners expect students to understand what each command does, when it should be used, and the risks involved if used incorrectly.
Why Data Modification Matters
Databases are not static. They must:
- Add new records
- Correct existing data
- Remove outdated or incorrect records
INSERT, UPDATE, and DELETE allow databases to reflect real-world changes, such as:
- New students enrolling
- Address changes
- Old records being removed
Understanding these commands is essential for explaining how databases are maintained.
What Is INSERT?
The INSERT command is used to add new records to a table.
INSERT:
- Creates a new row
- Adds data to specified fields
- Does not affect existing records
INSERT is used when:
- New data needs to be stored
- A new entity is added to the system
In IB terms, INSERT supports data creation.
Why INSERT Must Be Used Carefully
When inserting data:
