Explain the differences between char and varchar2 data types.
When a column is of type char, the memory used will not be dependent on the value. It entirely depends on the bytes defined.
Example:Name CHAR(10)
Each value will occupy 10 bytes of memory space even though the value may be of a smaller size.
When a column is of type varchar2, the memory used entirely depends on the value of the column.
Example:Name VARCHAR2(10)
Each value will occupy “x” bytes of memory space depending on the value.
To summarize, char data type is usually used when the value of fixed size is ascertained; for example Student id.
On the other hand, varchar2 should be used for variable length of data; for example Name.
Explain the differences between char and varchar2 data types.
The char data type accepts strings that are of fixed length.
The VARCHAR2 data type is a varying length data type.