Definition
Data Manipulation Language (DML) in Salesforce Apex refers to the set of operations used to insert, update, upsert, delete, undelete, and merge records in the Salesforce database. DML operations can be performed using DML statements (like insert account;) or Database class methods (like Database.insert(account, false)). DML operations are subject to governor limits, including a maximum of 150 DML statements per transaction.
Real-World Example
a developer at Quantum Labs recently implemented Data Manipulation Language (DML) to build a custom solution that extends the platform beyond its standard capabilities. They write clean, bulkified code for Data Manipulation Language (DML), add comprehensive test coverage, and deploy it through a CI/CD pipeline. The new functionality handles 10,000 records without hitting governor limits.
Why Data Manipulation Language (DML) Matters
DML in Salesforce Apex covers the operations that modify records in the database: insert, update, upsert, delete, undelete, and merge. You can perform DML two ways. As statements (insert myAccount;) the operation is all-or-nothing: any failure throws an exception and rolls back. Through the Database class (Database.insert(myAccount, false)) you get partial success: failures are returned as results without throwing, letting you handle errors per record. Both forms enforce governor limits.
The most important DML governor limit is 150 DML statements per transaction. This is one of the central reasons Apex code must be 'bulkified': processing records in collections rather than one at a time. A loop that does insert account; on each iteration burns one DML statement per record and hits the limit at 150 records, while a single insert accountList; covering 200 records uses just one DML statement. Bulkification is the single most common source of Apex bugs and the single most important pattern Apex developers must learn. Beyond statement counts, there are also row-count limits (10,000 rows per transaction across all DML operations).
How Organizations Use Data Manipulation Language (DML)
- •Quantum Labs — Refactored a trigger that was hitting DML limits at 150 records into a bulkified version that processes 10,000 records in a single insert. The refactor turned a brittle process into one that handles their largest data loads cleanly.
- •TerraForm Tech — Uses Database.insert with the allOrNothing=false flag for batch jobs that can tolerate partial failures. Failed records are logged and reprocessed instead of breaking the whole batch.
- •CodeBridge — Built a code review checklist that flags any Apex with DML inside a loop. The checklist catches bulkification problems before they reach production.
