This blog post helps to understand how and what are the different types of SOQL queries for fetching various types of information from salesforce….
1. Query for Field Level Security
Use the WITH SECURITY_ENFORCED clause to enable checking for the field- and object-level security permissions on SOQL SELECT queries, including subqueries and cross-object relationships.
SELECT Id, Name, StageName, ClosedDate FROM Opportunity WITH SECURITY_ENFORCED
If above Query throws an exception insufficient permissions. and no data return due to user not have permission to query this then use below type of query.
SELECT Id, (SELECT FirstName, LastName FROM Contacts), (SELECT Description, StageName, CloseDate FROM Opportunities) FROM Account WITH SECURITY_ENFORCED
2. Query Number of Objects list
To fetch all objects with names in your org, use below query.
SELECT MasterLabel, PluralLabel, KeyPrefix, DeveloperName, QualifiedApiName, NamespacePrefix FROM EntityDefinition WHERE IsCustomSetting = false Order by MasterLabel
Incase if you want to get Keyprefix of object
SELECT DeveloperName, KeyPrefix FROM EntityDefinition WHERE IsCustomSetting = false and QualifiedApiName = ‘ContentDocument’
3. Query to get List Views
Select DeveloperName, sobjectType From ListView where SobjectType = ‘Account’
4. Recently Viewed Records
If i want to see who viewed recently any account in your org.
Select Id, Name, Type, LastViewedDate, Profile.Name FROM RecentlyViewed WHERE Type ='Account' ORDER BY LastViewedDate DESC
5. Query Custom Buttons, Links & URLs
If you want to query custom buttons and custom links and URL buttons you can from info in Weblink object
Select Id, Name, LinkType, PageOrSobjectType From WebLink where NamespacePrefix = ”
you can filter Link type
6. Query Scheduled Jobs in your org.
All the scheduled jobs are stored in CronTrigger object in Salesforce.
SELECT ID, CronExpression, CronJobDetail.Name, CronJobDetailId, EndTime, NextFireTime, PreviousFireTime, StartTime, State, TimesTriggered FROM CronTrigger
7. Query Activity History on a Record
SELECT Id, (SELECT Id, Subject, CreatedDate FROM ActivityHistories WHERE CreatedDate = LAST_N_DAYS: 30) FROM Account WHERE Id = '001G000003Luh8''
8. Org wide Code Coverage
SELECT PercentCovered FROM ApexOrgWideCoverage
Facebook Page: Jayakrishna sfdc Blog – https://www.facebook.com/groups/615517438930811/