“ALL ROWS” keyword is used to fetch records form recycle bin in Salesforce.
Sample SOQL:
SELECT Id, AccountId
FROM Contact
WHERE IsDeleted = true
ALL ROWS
Execute the below code in Anonymous window to check the results.
Sample Code:
String strQuery = 'SELECT Id FROM Account WHERE IsDeleted = true ALL ROWS';
system.debug( Database.query( strQuery ) );
Another Apex Example:
System.debug(
'No of deleted PSRs is ' +
[
SELECT COUNT()
FROM PendingServiceRouting
WHERE IsDeleted = true
ALL ROWS
]
);