You need to sign in to do that
Don't have an account?

Truncate Custom Object: "instantaneous" removal of all rows from a custom object with limited options to recover the data.
We have a beta version of a functional equivalent of TRUNCATE SQL available on Sandbox organizations. Please open a case with support if you would like to try it out. We will make a decision on when to GA based on adoption and feedback.
Truncating a custom object does the following:
- Permanently disassociates ALL the object's data records from the object. You will not be able to operate on them using this object and they will not be recoverable from the Recycle Bin.
- Recalculates values in Roll Up Summary Fields in parent objects that reference the object. You will not be able to recover the values that existed prior to the truncate.
- Creates a "shadow" custom object . This is a deleted custom object associated with the truncated data records. Its name consists of the truncated object's name suffixed by "_trunc_n" where n is the number of times the object has been truncated. Like any deleted object, the shadow object will appear in the deleted objects list until you permanently erase the object and its data, or 45 days have passed. While it is in the deleted objects list you can undelete the "shadow" and the data stored in it to create a new custom object. An undeleted "shadow" custom object will not be a clone of the truncated table. It will not have any of the truncated object's :
- relationships with other objects. Any foreign key fields will be converted to read-only text fields.
- Autonumbers. AutoNumber fields will be converted to read-only text fields
- workflow rules or actions
- reports
- formula fields
- roll-up summary fields
- validation rules or approval processes
- Apex Code triggers
- translations
- field history
Greg,
Very interesting. I've got a few simple questions:
If you perform a TRUNCATE on the Object, will it fire the Delete Trigger on the Object?- Seems like no?
When you recover the custom object will it fire any UnDelete Triggers? - Seems like no?
Whats the advantage of performaing TRUNCATE versus doing a Mass Delete via DataLoader or Apex API Delete (Select Id from X__c); delete x;? API Call / SOQL / Goveronor Limits?
Just looking for some clarity on what might be good use case to use this versus other methods we've been using for a while.
Thanks!
Hi Rory,
No, it will not fire any triggers.
The advantage over mass delete, API or Apex is speed. This is the only way to delete all data without touching every row in the object. The speed to truncate will be the same whether the object has millions of rows or one.
Regards,
Greg
Good news with Winter '13: https://help.salesforce.com/HTViewHelpDoc?id=dev_object_trunc_overview.htm&language=en_US#TruncatingObjectsOverview
Please make this available to APEX or offer an alternative Lazy Delete or the like.
Thanks.