Howto wildcard SELECT * to query all fields of objects in APEX?

I have created sObject and I need all the fields and I have many. Is there a way I can directly get all of them rather then typing each one of them.


Spring ’21 Release (API v51+) adds new SOQL FIELDS function can select all fields of an object.
Refer to documentation

Knowing that new FIELDS function must have a LIMIT of at most 200, when used with ALL or CUSTOM keyword, the workaround below can still be useful.

There is no way to Select * with SOQL.

You can however work-around this limitation by using dynamic SOQL and describe methods to get all of the fields on the object. This is described in detail in this post by Cory Cowgill:

Building Dynamic SOQL – Select All Query

Source : Link , Question Author : NewBei , Answer Author : Shamina

Leave a Comment