Write a SOQL query to find all AccountShare records for a specific Account to inspect manual and Apex sharing reasons (RowCause).
Answer
Each sharing-enabled object has a Share object (e.g. AccountShare) holding the sharing grants. Filter by AccountId and inspect RowCause to see why access exists.
soql
SELECT Id, AccountId, UserOrGroupId, AccountAccessLevel, RowCause
FROM AccountShare
WHERE AccountId = :accId
RowCause values include Owner, Manual, Rule, Team, Territory, and Apex sharing reasons for custom objects.
soqlscenariosharingsetup-objects