This might not be a question but a technical memo for future reference

Deleted records query command (example):

SELECT Count() FROM Contact WHERE IsDeleted = true ALL ROWS
SELECT Id, LastName, IsDeleted FROM Contact WHERE IsDeleted = true ALL ROWS

Query editor of the developer console does not support "ALL ROWS" keyword thus it does not support deleted records query.

The error message is "Unknown error parsing query" and the screenshot is as below. enter image description here

But, the same commands work fine in Developer console's Anonymous Execution

The commands

Integer deletedContacts = [ SELECT COUNT() FROM Contact WHERE IsDeleted = true ALL ROWS ];

And the result

enter image description here


2 Answers 2


The developer console and anonymous apex are running the SOQL query via two different mechanisms.

For anonymous apex the ALL ROWS statement is the correct way to identify that you want to include deleted records and archived activities in the results.

The developer console query window isn't running the query via apex. Instead it is directly using the APIs to run the SOQL query. While ALL ROWS is valid syntax in the query, it doesn't actually do anything against the API.

If you look in the REST API docs, you will see that there are two query resources.

  1. query
  2. queryAll

Only queryAll will actually find the deleted records in the same way that ALL ROWS would in Apex. Currently the developer console won't detect the presence of ALL ROWS and switch to the correct API endpoint. As such, it never returns deleted records.

The idea that Raul linked to is one option to ask for this functionality - Allow use of "ALL ROWS" within Developer Console query editor


Another option that I found useful is using Workbench, https://workbench.developerforce.com/

You can paste in your SOQL query without the "ALL ROWS" keyword, and be sure to choose Include "Deleted and Archived Records" option.

Workbench option

I hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .