If we want to save records in the database on a permanent basis, we use DML statements in salesforce. We have multiple DML statements through which we can insert, update, delete or undelete records in the Salesforce database.
Some are mentioned below:
It is used to insert new records into any object. In this, row identification is not required due to the insertion of records.
Here I want to insert Account record with Account name as ‘New Account’ and Industry as chemical.
Account acc = new Account();
acc.Name = ‘New Account’;
acc.Industry = ‘Chemicals’;
It is used to modify the existing data or records. Row identification is required since we are updating the records. So, we need to identify which record to update.
Update the type to ‘prospect’ and Industry as ‘Banking’ of the Account object.
acc.type = ‘Prospect’;
acc.Industry = ‘Banking’;
It is used to delete the existing records present in our salesforce org.
Once the record is deleted, it will go to recycle bin for 15 days. Within 15 days, we can restore our records, after that, they will be no more present in our org.
The record will be deleted and stored in the recycle bin.