You need to sign in to do that
Don't have an account?
rezasadoddin1.3878325535858708E12
Deleting all the records of a custom object
How can I delete all the records of a custom object in Developer Edition?
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Go to the Developer Console in the upper right of your web brower. Click Debug -> Execute Anonymous Apex.
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.
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
I think you can use 'Truncate' option to delete all records in a custom object.
for more reference please go through the below URL.
https://help.salesforce.com/HTViewHelpDoc?id=dev_object_trunc_overview.htm&language=en_US
Regards,
Sridhar Bonagiri
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/
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.
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
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.
You can try this one,
Pls, Mark it as the Best answer If You find it helpful !!
Thanks