Using SOQL, how do I truncate an object or delete all rows. For example

DELETE (Select id FROM MyObject__c)


delete [select Id FROM MyObject__c]



All 3 example commands in the Developer console returns:

The query has to start with 'FIND' or 'SELECT'

You can't perform any DML using SOQL. The 'Q' stands for 'Query'.

If you want to use Execute Anonymous, then you can use:

delete [select id from myobject__c limit 10000];

However, this has a 10,000 row limit, so that might not be appropriate in all cases.

Salesforce can query 50,000 records at a time but due to governor limit it'll allow only 10,000 DML operation

The only way to perform a quick truncate would be to use the UI to initiate the truncate.

  • Thanks - That's a horrible limitation. But it is what it is. – PhillyNJ Mar 2 '15 at 20:41
  • So there is no way to test this via Console and I eventually need to do this via SOAP, it looks like the best option is to use a Select() then Delete() salesforce.com/developer/docs/api/Content/… – PhillyNJ Mar 2 '15 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.