Thanks for the explaination. Heh I should have realized that. varchars are
probably implemented as null terminated strings and so they need an extra
byte for the terminating char (Null or otherwise).

Yeah it's definitely doing me a favor as my reason for varchar was space.
So what happens if I store a single char in a field of char(2)? Does it get
autofilled then? I saw an option for this so do I have to specify that this
field should get autofilled?

I'm definitely gonna have to read that manual you gave me the link to I
see. That default thing means I'm gonna have to re-do all the SQL in that
application. *sigh* I just knew I would. I fought a good fight I guess.

On Sun, 18 Apr 2004 15:03:18 -0400, Michael Stassen wrote:

> In MySQL, the only practical difference between a CHAR and a VARCHAR is how 
> it is stored.  CHARs are fixed-length, so they are fast but can waste space. 
>   VARCHARs are variable length, so they are slow but (usually) save space. 
> That's the key here -- the only advantage to a varchar is the space savings. 
>   But, each varchar takes one more byte than the length of the string in 
> order to store the length.  When your column is less than 4 characters, that 
> extra byte makes a significant dent in your space savings, thus removing the 
> sole advantage of varchar over char.  For example, it takes 2 bytes to store 
> a CHAR(2) and 1 to 3 bytes to store a VARCHAR(2).  MySQL is trying to do you 
> a favor by changing your column.  Whether you agree it's done you a favor or 
> not seems to be a matter of opinion.
> 
> You should definitely read the "Silent Column Specification Changes" 
> <http://dev.mysql.com/doc/mysql/en/Silent_column_changes.html> section of 
> the manual.
> 
> Michael

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Stormblade (Shaolin Code Warrior)
Software Developer (15+ Years Programming exp.)

My System: http://www.anandtech.com/mysystemrig.html?rigid=1683
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to