SQL Practice Logo

SQLPractice Online

INSERT, UPDATE, DELETE Statements: Performance

Module: SQL Fundamentals

**Safety Rules:**

• Always use WHERE in UPDATE/DELETE (or you'll modify ALL rows)

• Use transactions for safety: BEGIN; UPDATE...; ROLLBACK/COMMIT;

• Test with SELECT before UPDATE/DELETE

• Backup data before bulk modifications

• Check foreign key constraints before DELETE

Batch INSERT multiple rows in single statement

Index columns used in UPDATE/DELETE WHERE clause

Use TRUNCATE instead of DELETE for entire table (faster)

Disable indexes before bulk INSERT, rebuild after

Forgetting WHERE in UPDATE/DELETE (modifies ALL rows)

Not using transactions (cannot undo mistakes)

Violating foreign key constraints

Not checking affected row count

Inserting NULL into NOT NULL columns