1. Primitive DataTypes:
Integer, Double, Decimal, Long, String, Boolean, Date, Time, DateTime, Blob, Object, ID.
1.Integer: It allows us to store the numerical values with out any decimal points.
Ex: 100, 4500,200000
Note: Each Integer value will consume 4 -Bytes of memory.
Range: -2^31 to +2^31-1.
Note: Each Number Field, Percent Field, Currency field will reference the Integer DataType.
2.ID DataType: It allows us to store either 15 / 18 characters record id.
Note: Each Id Field, Ownerid field, Lookup Relationship, Master-Detail Relationship, Hierarchical Relationship, External Object Lookup Relationship will reference the “ID DataType” by default.
3.String DataType: It allows us to store the Alphanumerical values along with the special characters.
Note: All the string values should be enclosed inside the “Single Quote”.
Ex: ‘Rohit Sharma’ ‘R’
Note: Each Character inside the string variable will occupy one-byte of memory.
Ex: ‘Rajesh Kumar’ –> 12 Bytes
Note: Each Text Field, TextArea, TextArea Long, TextArea Rich, Email, URL, Text Encrypted, Auto Number, Phone, GeoLocation, Picklist, Picklist-MultiSelect fields will reference the String DataType by default.
4.Boolean: It allows us to store either TRUE / FALS value inside the variable.
Note: Each Checkbox field type will reference the “Boolean DataType” by default.
5.Date: It allows us to store the Date values inside the variable.
Note: All the “Date Fields” inside the object will reference the “Date DataType” by default.
6.Time: It allows us to store the Time values inside the variable either in “12 / 24 Hours” format.
Note: Each Time Field will reference the “Time DataType” by default.
7.DateTime: It allows us to store both Date and Time Stamp value inside the variable.
Note: Each DateTime Field will reference the “DateTime” datatype by default.
Ex: CreatedBy, LastModifiedBy, DeletionDate,..etc.
8.Long: It allows us to store the Larger integer values between the range -2^63 to +2^63-1.
Note: Each Long DataType variable will occupy the 8-Bytes of Memory.
9.Decimal: It allows us to store the Numerical value including the “Decimal Digits”.
Note: Each Currency field will reference the “Decimal DataType” by default.
10.Double: It allows us to store the Numerical values including more number of digits after the decimal point.
Ex: 3.1416, 3.3333333333,…etc.
11.Blob: (Binary Large Objects
It allows us to store the Binary Content of an image / picture / Audio / Video files/ Word or PDF Documents,…etc.
Note: Each Document Object, Attachment Object, and Static Resource will reference the “Blob DataType” by default.
12. Object: It is a Generic DataType, which allows us to store any Type of value inside it.
2. SObject DataTypes:
Standard + Custom Objects = SObjects. (Salesforce Objects)
Each Object in salesforce will be represented in the form of a “Class”.
Ex: Account Object will be represented in the form of an Account Class.
Ex: Public Class Account
Customer Object will be represented in the form of a “Customer__C” class.
Ex: Public Class Customer__C
Note: Primitive DataTypes purely supports the “Static Memory Allocation”. (i.e. Upon defining the variable, the memory will be getting reserved). Which causes the “Memory Wastage”.
SObject DataTypes are purely supporting the “Dynamic Memory Allocation”, which provides the efficient utilization of memory. (i.e. There is No Memory Wastage in Dynamic Memory allocation)
All the Primitive DataType elements will get stored inside the “Stack Memory”.
All the SObject Type elements will get resides inside the “Heap Memory”.