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]
TRUNCATE TABLE 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:
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.