Apex Data Manipulation Language (DML) Operations

Use data manipulation language (DML) operations to insert, update, delete, and restore data in a database.

You can execute DML operations using two different forms:

While most DML operations are available in either form, some exist only in one form or the other.

The different DML operation forms enable different types of exception processing:

The following Apex DML operations are available:

System Context and Sharing Rules

Most DML operations execute in system context, ignoring the current user's permissions, field-level security, organization-wide defaults, position in the role hierarchy, and sharing rules. However, when a DML operation is called in a class defined with the with sharing keywords, the current user's sharing rules are taken into account. For more information, see Using the with sharing or without sharing Keywords.

String Field Truncation and API Version

Apex classes and triggers saved (compiled) using API version 15.0 and higher produce a runtime error if you assign a String value that is too long for the field.

1convertLead is only available as a database method.
2merge is only available as an Apex DML statement.
© Copyright 2000–2012 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.