I am wondering if I have a VARCHAR of 200 characters and that I put a string of 100 characters, will it use 200 bytes or will it just use the actual size of the string?
100 characters.
This is var (variable) in varchar : you only save what you type (and an extra 2 bytes for storing lengths up to 65535)
varchar
If it was char(200) then you should always keep 200 characters filled with 100 spaces
char(200)
See documents: Types CHAR and VARCHAR
VARCHAR means it is a variable-length character, so it takes up as much space as necessary. But if you knew something about the underlying structure, it might make sense to limit VARCHAR to some maximum amount.For example, if you save comments from the user, you can limit the comment field to only 4000 characters; if so, then it doesnโt really make sense to make the sql table a field that is larger than VARCHAR (4000).
VARCHAR means it is a variable-length character, so it takes up as much space as necessary. But if you knew something about the underlying structure, it might make sense to limit VARCHAR to some maximum amount.
For example, if you save comments from the user, you can limit the comment field to only 4000 characters; if so, then it doesnโt really make sense to make the sql table a field that is larger than VARCHAR (4000).
http://dev.mysql.com/doc/refman/5.0/en/char.html
Actually, it will take 101 bytes.
MySQL Reference