function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
King KooKing Koo 

Question about "ALL ROWS" in SOQL

Hi there


It seems to me that the "ALL ROWS" keyword that you use in SOQL (to access records in the recycled bin) can only be used in Apex.


I went to Developer Console in the Query Editor and tried typing this



and it executes.


But If I add "ALL ROWS" at the end, i.e.



then I got

"Unknown error parsing query" error.


If I write this in an Apex code, like this


List<Fruit__c> fruits = [SELECT ID FROM Fruit__c ALL ROWS];


then the line actually executes successfully.


It seems weird to me that "ALL ROWS" keyword cannot be used inside the Query Editor.  Wondering if anyone has encountered that?




The query editor doesn't use Apex Code-- it executes directly as a REST query API call. There's no way to query deleted records from the developer console's query editor at this point. Use the Apex Data Loader (Export All), or the workbench (
Groundwire ConsultingGroundwire Consulting



SOQL statements can use the ALL ROWS keywords to query all records in an organization, including deleted records and archived activities. 

For example:


 [SELECT COUNT() FROM Contact WHERE AccountId = a.Id ALL ROWS]);


You can use ALL ROWS to query records in your organization's Recycle Bin. You cannot use the ALL ROWS keywords with the FOR UPDATE keywords.


and if you have any more questions please feel to contact me on

You can't use that in Developer Console's Query Editor. ALL ROWS and FOR UPDATE are Apex Code only SOQL features.
A AdityaA Aditya
Hi, can anyone explains me how to use ALL ROWS in query, because im getting an error MAL-FORMED Query.
My requirement is to now the deleted records using query

Added Idea for allowing ALL ROWS in Developer Console:
Justin J. YueJustin J. Yue
You cannot do it directly within the Query Editor of developer console but there's a workaround for you to test your query in Developer Console. The workaround is to use the "Execute Anonymous Window".

1. Open "Enter Apex Code" window by selecting "Debug" -> "Open Execute Anonymous Window" menu
2. Enter your query there and output the result to the log. Check the "Open Log" checkbox. 

List<Fruit__c> fruits = [SELECT ID FROM Fruit__c ALL ROWS];

3. Click "Execute" to run your code and check the log file for your result.

Soumya BeheraSoumya Behera
Thank you Just In You. Your solution worked . Its helped me to find the solution quickly.
select id,isDeleted from account where isDeleted = true

this one is working in query editer...
SalesForce Admin 355SalesForce Admin 355

"just in you"'s  workaround works  


David Roberts 4David Roberts 4
Here's a similar piece of code to find archived events. Adjust the query parameters to suit.

integer iCount = 0;
event[] queriedObjects =
[SELECT Id,isarchived,activitydate,subject from Event  where (activitydate = 2017-01-04 and isarchived = true and isdeleted = false) ALL ROWS];
    for (event e : queriedObjects) {
        iCount = iCount + 1;
        system.debug('event = '+e.isarchived + '--' + e.activitydate + '--' + e.subject);
    system.debug('final count = '+iCount);
J PaulJ Paul
The easy answer is to run your query in Workbench and choose the 'Include' option under 'Deleted and archived records'. 
David Roberts 4David Roberts 4
Hi Jason, Yes, it doesn’t work in the query editor. However, it does work in the execute anonymous window. You need to be slightly codey. List lstFruit = [SELECT ID FROM Fruit__c ALL ROWS]; You’ll then need to list the results possibly in chunks if there are lots (and hope you haven’t exceeded your governor limits). integer iCount = 0; for ( Fruit__c aFruit : lstFruits ) { iCount +=1; system.debug(iCount+' '+aFruit.Id); } Regards, Dave.
Kurt RolsonKurt Rolson

Po 4 długich latach, związek Tessy i Hardina zostaje w końcu wystawiony na próbę. Kiedy na jaw wychodzą mroczne rodzinne sekrety, okazuje się, że najtrudniejsza próba ze wszystkich jest jeszcze przed nimi. Czy uda im się znaleźć sposób, by wybaczyć sobie nawzajem i ruszyć dalej? A może ich miłość zostanie zniszczona przez ujawnione rewelacje?

rimenz joerimenz joe
We will use the LookupRows function to look up all rows, that match the Id of the Customer, that we want to send the email to.
Iren MayIren May
Good thing I read this, I have a problem with it too.
Kurt RolsonKurt Rolson
To wzruszająca historia dwojga ludzi, którzy spotykają się i zakochują w sobie podczas sezonu wakacyjnego. Kontynuują randki i planują żyć długo i szczęśliwie, dopóki ich rodziny nie staną na przeszkodzie. Nawet w obliczu dużej odległości, ta para kontynuuje walkę o swoją miłość i ostatecznie pokonuje wszelkie przeszkody, które pojawiają się na ich drodze.