Apex enables you to insert, update, delete or restore data in the database. DML
operations allow you to modify records one at a time or in batches.
-
How DML Works
-
Adding and Retrieving Data With DML
Apex is tightly integrated with the Lightning Platform persistence layer. Records in the database can be inserted and manipulated through Apex directly using simple statements. The language in Apex that allows you to add and manage records in the database is the Data Manipulation Language (DML). In contrast to the SOQL language, which is used for read operations (querying records), DML is used for write operations. -
DML Statements vs. Database Class Methods
Apex offers two ways to perform DML operations: using DML statements or Database class methods. This provides flexibility in how you perform data operations. DML statements are more straightforward to use and result in exceptions that you can handle in your code. -
DML Operations As Atomic Transactions
-
DML Operations
Using DML, you can insert new records and commit them to the database. You can also update the field values of existing records. -
Exception Handling
-
More About DML
Here are some things you may want to know about using Data Manipulation Language. -
Locking Records
When an sObject record is locked, no other client or user is allowed to make updates either through code or the Salesforce user interface. The client locking the records can perform logic on the records and make updates with the guarantee that the locked records won’t be changed by another client during the lock period.