eMonk Posted April 25, 2011 Share Posted April 25, 2011 My book recommends using char over varchar because it will keep the database smaller and it's faster to phrase. So why is everyone using varchar? Quote Link to comment https://forums.phpfreaks.com/topic/234690-char-vs-varchar/ Share on other sites More sharing options...
Maq Posted April 25, 2011 Share Posted April 25, 2011 My book recommends using char over varchar because it will keep the database smaller and it's faster to phrase. So why is everyone using varchar? They're stored differently and CHAR can only hold up to 30 characters. Read more here: http://dev.mysql.com/doc/refman/5.0/en/char.html Quote Link to comment https://forums.phpfreaks.com/topic/234690-char-vs-varchar/#findComment-1206050 Share on other sites More sharing options...
mikosiko Posted April 25, 2011 Share Posted April 25, 2011 ... CHAR can only hold up to 30 characters. ... oops!! char() ... 0-255 varchar() 0-65535 main difference (other than the size limit) is the way that both are stored char() is fixed length (right-padded) and varchar() is variable length Quote Link to comment https://forums.phpfreaks.com/topic/234690-char-vs-varchar/#findComment-1206054 Share on other sites More sharing options...
eMonk Posted April 25, 2011 Author Share Posted April 25, 2011 Why do I always get the wrong answers on this forum lol. Just saying. Quote Link to comment https://forums.phpfreaks.com/topic/234690-char-vs-varchar/#findComment-1206055 Share on other sites More sharing options...
mikosiko Posted April 25, 2011 Share Posted April 25, 2011 c'mon Emonk what do you expect after a longggg weekend? that happens to all of us sometimes ... but most of the time answers are right on the spot so don't lose faith Quote Link to comment https://forums.phpfreaks.com/topic/234690-char-vs-varchar/#findComment-1206058 Share on other sites More sharing options...
Maq Posted April 25, 2011 Share Posted April 25, 2011 Why do I always get the wrong answers on this forum lol. Just saying. Yeah sorry. Read the example in the manual and just typed 30 characters without thinking. Quote Link to comment https://forums.phpfreaks.com/topic/234690-char-vs-varchar/#findComment-1206061 Share on other sites More sharing options...
raindropz12 Posted April 26, 2011 Share Posted April 26, 2011 what is the difference between fixed-length and variable-length? Quote Link to comment https://forums.phpfreaks.com/topic/234690-char-vs-varchar/#findComment-1206316 Share on other sites More sharing options...
fenway Posted April 26, 2011 Share Posted April 26, 2011 The refman covers it all -- there are dozens of other subtle differences (trimming, index implications, etc.). More importantly, one variable-length column means you can't have any CHAR fields anymore. Quote Link to comment https://forums.phpfreaks.com/topic/234690-char-vs-varchar/#findComment-1206395 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.