In this article you will learn how to get List of all present and deleted records from salesforce object using apex query. Following code will retrieves deleted and present records from Account object.
List records = [SELECT Id from Account ALL ROWS];
ALL ROWS keyword in a SOQL query retrieves all the records from the database, including those that have been deleted.
The following code will return only deleted records from Account object.
List deletedRec = [SELECT Id from Account where isDeleted = true ALL ROWS];
Check out how to write a Trigger to permanently delete a record using emptyRecycleBin.