How to query Field History Tracking records in Salesforce?

If field history tracking is enabled for an object, the changes are stored in history table for that particular object.

The API name of these tables follows a simple convention so should be easy to find. For standard objects, the name of the history table follows the format: 'ObjectNameHistory' so for the Account object the history table is AccountHistory.

For custom objects, the name of the convention simply replaces the 'c' on the end of the API name with 'History'. So, for a custom object call My_Custom_Object__c the history table is called My_Custom_Object__History.

Sample Queries:

SELECT AccountId, OldValue, NewValue, IsDeleted, Id, Field, CreatedBy.Name From AccountHistory WHERE AccountId=:accountId ORDER BY CreatedDate DESC

SELECT Id, Name, (Select OldValue, NewValue From My_Custom_Object__History) FROM My_Custom_Object__c