Salesforce.com – Quick Tip – Delete all records from an object

Sometimes you want to delete all the records from an object and wonder how to do it ?

Here are some tips :

  1. Export all records (just record id should be fine) in Data loader or any ETL tool and use Delete operation to delete them. This will be a slower as this operation takes 200 records at a time. You can use bulk API but won’t make much difference
  2. Write a batch class to query and delete records. I  hope you won’t do it just to delete records :).
  3. Use Truncate button on the object detail page to delete all the records at once.  But this button should enabled and can only work for custom objects.

Hope this helps some one out there. ..

Keep reading and sharing. ..


Comments

  1. […] Source: Salesforce.com – Quick Tip – Delete all records from an object […]

  2. webmaster Avatar

    Truncate isn’t always available. It is available if the object is standalone without any lookup/MD relationship.

    1. Yes, the option needs to be enabled and will work only with custom objects where there are no lookups, indexing is not done and no external id fields are there .

Leave a Reply

Your email address will not be published. Required fields are marked *