Saturday, December 5, 2009

What is the difference between char and varchar data types?

Set char to occupy n bytes and it will take n bytes even if u r
storing a value of n-m bytes
Set varchar to occupy n bytes and it will take only the required space
and will not use the n bytes
eg. name char(15) will waste 10 bytes if we store 'mysql', if each char
takes a byte
eg. name varchar(15) will just use 5 bytes if we store 'mysql', if each
char takes a byte. rest 9 bytes will be free.

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off