4
Reply

How the processing of char and varchar is different. Which one data type you will prefer and why?

Puran Mehra

Puran Mehra

14y
7.7k
0
Reply

    Hi,

    Both the datatypes have their own significance.
    Memory wise, varchar is the better one,
    but for performance, char is suggestible ..
    so it purely depends on your requirement.
    But one thing is that varchar uses Unicode standard
    where as char doesnt..
    Thank You 

    "varChar" can adjust according to the requirement but 'char" cannot adjust that is why I will prefer "varChar" to save the memory space.

    Main different between char and varchar is memory. See this example:

    It is the structure of a table "emp"

    empcode1 char(5),

    empcode2 varchar(5)

    So if i have inserted value of 4 characters in every column link "s001" then column "empcode1" will occupy 5 byts in memory but column "empcode2"

    will occupy only 4 byts in memory.  varchar utilize memory according number of characters but char will utilize memory according to its size.

    Varchar is variable length and char is fixed length.

    We should use char when size of column data is fixed.

    We should use varchar when size of column data is not fixed.

    char take only character values like a,b,c etc . but varchar can take any character,special char,numeric also.

    so i will prefer varchar datatype because u can take any type of data by using varchar data type.