function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jude Shoop 35Jude Shoop 35 

What is a simple query to get object name, type & record count?

AnkaiahAnkaiah (Salesforce Developers) 
Hi Jude,

to query list of objects use the below query.
SELECT  QualifiedApiName FROM EntityDefinition order by QualifiedApiName
https://salesforce.stackexchange.com/questions/100668/retrieve-api-names-of-all-object-in-salesforce-org-using-soql

If you want to query the record count of specific object then try with below query.
SELECT COUNT(Id) from Account

Refer the below links
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_count.htm

If this helps, Please mark it as best answer.

Thanks!!
Mary FieldsMary Fields

1) Open the Developer Console, In Query Editor & execute simple query as "SELECT id FROM Acccount", you will get the number of record in Query Results.

2) If you want to use this count in Code, you can write query as 
Integer count = SELECT count() FROM ObjectName;
Check count you will get number of records from object, 

more information is here: https://developer.salesforce.com/docs/ (https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_count.htm)

Thanks,

https://www.gta-portal.com/

Shri RajShri Raj
SELECT SobjectType, Count(Id) recordCount FROM [ObjectName] GROUP BY SobjectType

 
Jude Shoop 35Jude Shoop 35
Thank you for your answer, but what if I want a list of all objects & record count and not do it 1 by 1? Jude Shoop Sr. Analyst – Technical Information Applications [iTeamLogRVB] Arkema Inc. 900 First Avenue King Of Prussia, PA 19406 Office: 610.205.7194 Mobile: 610.304.5608 [cid:image002.jpg@01D93626.8AFA58E0]
Eric Morgan 10Eric Morgan 10

It depends on the specific programming language and database you are using. Here's an example in SQL for getting object name, type and record count from a relational database:

SELECT object_name, object_type, COUNT(*) as record_count
FROM information_schema.tables
GROUP BY object_name, object_type;

This query retrieves the object_name, object_type and count of records for each table in the database. The information is fetched from the information_schema.tables table, which is a standard table in most relational databases and provides information about the tables in a database.

 

Thanks,

https://www.nextemployeeportal.com/

Chase FrisbieChase Frisbie
I will figure out more on that. DG Paystub (https://www.dg-paystub.com/)