Developer Console - Delete Multiple Records

  • Is there a DML or other way to delete all records from the developer console? For example, we have 100K Leads in our testing environment and we would like to delete all of them in one operation.

    Is that possible?

    By the way, I saw there is a mass delete option, although it only lets you delete a few hundreds records at a time.... (using Setup-> Administration Setup->Data Management -> Mass Delete Records.)

  • Phil Rymek

    Phil Rymek Correct answer

    8 years ago

    You can delete records from the developer console with the line

    delete [SELECT Id FROM MyObject];
    

    However, this isn't going to delete 100k records successfully due to governor limits. You're going to need to use dataloader to export the 100k records, then use the export to delete the records.

    Edit: Better than that, you can use LIMIT to select a subset, and then rerun the command after each execution

    delete [SELECT Id FROM MyObject LIMIT 10000];
    

    Is this answer still valid? When I try it I got error "Invalid query: The query has to start with 'FIND' or 'SELECT'"

    This answer is still valid, at least for standard objects like 'Contact'. I was able to delete records with a vengeance. (This is far superior to the troublesome 'mass delete' interface that deletes 250 at a time, assuming there no hidden errors that don't allow records to be deleted..!

    I am not able to use delete for deleting Contacts in developer console. I tried the SOQL and it did not work. Got the error mentioned by @Zorji

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM

Tags used