> ## Content Index
> Fetch the complete content index at: https://www.namastesalesforce.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# 04 · DML and the database
- URL: https://www.namastesalesforce.com/courses/apex-beginners/dml-and-the-database/
- Published: 2025-05-31T09:00:00.000Z
- Updated: 2025-05-31T09:00:00.000Z
- Description: insert, update, upsert, delete — and what happens to the transaction when one record out of two hundred fails.
- Author: Swarnil Singhai
- Tags: Apex for Absolute Beginners, #lesson, #duration-20m, #Import 2026-09-03 19:13

insert, update, upsert, delete — and what happens to the transaction when one record out of two hundred fails.

## All or nothing, unless you ask

Plain DML rolls the whole batch back on one failure; Database.insert(records, false) lets the rest through and hands you the errors. Know which one each situation needs.

## Upsert and external IDs

Upsert against an external ID field is the backbone of every integration you will ever build. We set one up and watch it match.

## Practice in your org

- Open your Developer Edition org and follow along step by step
- Change one thing at a time and note what happens
- When something breaks, read the error before searching for it