MySQL Forums
Forum List  »  General

Re: Text(1024)
Posted by: Rick James
Date: April 03, 2011 07:45PM

> That's a BIG waste of storage
Eh?

VARCHAR(1024) consumes 2 bytes plus just enough space to hold the string you insert.

If the string is 'abcde', the field takes only 7 bytes.

CHAR(1024), on the other hand, always occupies 1024 bytes. (Well, there are exceptions). CHAR should be used only when you know that all the values are the same length.

VARCHAR(1024) CHARSET utf8, with 10 character Chinese string will take 32 bytes of storage (2-byte length + 3 bytes per 'character').

Options: ReplyQuote


Subject
Written By
Posted
April 03, 2011 02:54AM
April 03, 2011 08:06AM
April 03, 2011 08:10AM
April 03, 2011 08:21AM
April 03, 2011 08:25AM
April 03, 2011 05:21PM
April 03, 2011 05:30PM
Re: Text(1024)
April 03, 2011 07:45PM
April 03, 2011 08:00PM
April 03, 2011 09:04PM
April 03, 2011 09:17PM
April 03, 2011 10:29PM
April 04, 2011 02:23AM
April 04, 2011 02:28AM
April 04, 2011 02:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.