Page 1 of 1

Text datatype

Posted: Sun Mar 30, 2003 11:49 pm
by fractalvibes
I had designed a MySQL table with one column defined as VarChar(250).

When I asked for some data to test with, I quickly realized that the column needed to be more like 3000 bytes. The Mascon client I often use would let me specify a text column, but not the max size.

Question is - if we add a row that simply has ABC - is this variable length, and am I just storing those three bytes plus whatever is needed to store the length of that field, or am I storing some huge - 2^16 or some such?

A little worried, as I could not specify a max size, but I gather that this is
calculated and taken care of by MySql...

thanks,

Phil J.

Posted: Mon Mar 31, 2003 1:25 am
by haagen
If you need to have bigger fields you have to use the blob fields. I think thers two diffrent kinds in mysql, binary and text. You probably want to use a text-blob if you just want to store a string. You do not need to specify the size of the blob, I think theres three diffrent type's of binary and text blob. The type determines the max-size.

Check the mysql manual pages for more info.

Posted: Mon Mar 31, 2003 2:53 am
by twigletmac

Posted: Mon Mar 31, 2003 9:30 pm
by fractalvibes
Thanks for the reply, Haagen and Mac. I am used to supplying a maxsize even with BLOB datatypes in DB2, so I was left with an uneasy feeling when MySQL would not allow this...

So I gather that a column defined as Text, in a particular instance I store the string 'ABC' - it actually is storing only 3 bytes plus however many bytes are needed to represent the actual size? i.e. variable length.

thanks,

Phil J.

Posted: Mon Mar 31, 2003 11:28 pm
by haagen
I think it's 4 bytes + data size. It's all in the manual :)