Inside Apex, you can get this by executing the following Apex code snippet. If your table / object has the name MyObject__c , then this will give you a set of API names of all the fields of this object that you have access to (this is important, even as a system administrator, if certain fields on your table / object are not visible using security at the field level, they will not be displayed here):
// Get a map of all fields available to you on the MyObject__c table/object // keyed by the API name of each field Map<String,Schema.SObjectField> myObjectFields = MyObject__c.SObjectType.getDescribe().fields.getMap(); // Get a Set of the field names Set<String> myObjectFieldAPINames = myObjectFields.keyset(); // Print out the names to the debug log String allFields = 'ALL ACCESSIBLE FIELDS on MyObject__c:\n\n'; for (String s : myObjectFieldAPINames) { allFields += s + '\n'; } System.debug(allFields);
To complete this and achieve the SELECT * FROM MYTABLE functionality, you will need to build a dynamic SOQL query using these fields:
List<String> fieldsList = new List<String>(myObjectFieldAPINames); String query = 'SELECT ';
zachelrath
source share