views:

132

answers:

1

Hi All,

I want to know if mysql TEXT data type reserves any space even if there is no data in that row? I am little confuse. Can anyone provide me any input on this.

Thanks in advance.

+2  A: 

Typically, no. text columns are actually stored away from the row, so they don't take up space on the row, per se. Instead, the row keeps a pointer to the text column (which does take up space, but only 4 bytes-ish (depends on the system) a row), but the text column itself will remain empty until you populate it.

Now, varchar columns will allocate space for their max at insertion, but only take up the space needed by its contents. char columns, however, will always use the space specified. So, here's what each column looks like with the phrase "waffles":

varchar(15): 'waffles'
char(15):    'waffles        '
text:        'waffles'

Hopefully, this helps.

Eric