+ Start a Discussion

Deleting all the records of a custom object

How can I delete all the records of a custom object in Developer Edition?
Cory CowgillCory Cowgill
If this is Developer Edition, and you have less than 10,000 rows of data, the easiest way may be to just do the following:

Go to the Developer Console in the upper right of your web brower. Click Debug -> Execute Anonymous Apex.

Delete SOQL

Enter in a SOQL to select all the records from the object. Then click Excecute. You'll get a success like the below:


Now all your records have been deleted.
Go to developer console >Debug > open Execute anonymous window

Write the following code:

List<Sobject__C> SobjLst = [select id from Sobject__C];
delete SobjLst;

click on the execute button.
note: Replace the Sobject__C with actual custom object api name

Thansk for your clear and detailed answers.
Sridhar BonagiriSridhar Bonagiri

I think you can use 'Truncate' option to delete all records in a custom object.

for more reference please go through the below URL.


Sridhar Bonagiri
Cory CowgillCory Cowgill
Truncate has serious limitations. It won't work with objects that have relationships (lookup fields) a and other nuances. I have found using SOQL deletes more effective with small batches of deletes.

I had to delete all the data or case numbers of a custom object. What I simply did is used the below query to fire and delete all the data in one go.
Open developer console/Debug/Open Execute Anonymous window/

delete [select Name from LogCase__c];

This can be extremely dangerous so use it very carefully. Also do it only when you know the exact impact of doing it.
After deleting the records, I did not find the data in the Recycle Bin. So be carefull.

marvin diligencia 16marvin diligencia 16
Thank you this is really helpful ! :)
Sarathy JPSarathy JP
Thanks it works Fantastic!
Gopala Karthigai Selvan MurugesanGopala Karthigai Selvan Murugesan
What if we have more than 10000 records in that custom object???
David @ ConfigeroDavid @ Configero
If you have less than 10,000 records you can run delete [SELECT Id FROM SObject LIMIT 10000] as anonymous apex code through the developer console or other IDE of your choice that utilizes Salesforce's APIs.

If you have more than 10,000 records and it is reasonable, just run a delete [SELECT Id FROM SObject LIMIT 10000] a few times, assuming this is a one off scenario you won't be repeating frequently or scheduled.  if this is a repeated/scheduled action, you might want to look into a batch and/or scheduled job, or using the bulk API which would be excellent for this as well https://developer.salesforce.com/page/Bulk_API
Bhanu joshi 10Bhanu joshi 10
We can export data using data loader and then delete them on the bases of Id's ,if we have more than 10K records
With the data storage limitations in Developer org, chances are less than the object will have more than 20K records. Which means, running the code snippet provided by @Cory Cowgill twice will do the job.
If you are so particular about the best practice, you can do this in two ways:
1. Use data loader/workbench to export the ids of the records and use the delete operation of DL/workbench to delete them.
2. Create a batch apex, which queries all records in the start method. In executing method add them to list and delete the records. Run the batch suing dev console.This ensures that you don't run into any governor limits.