FiREFLi Posted December 2, 2007 Share Posted December 2, 2007 What's best? I think most data types have specific limits don't they? Which one most efficiently scales up/down? Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/ Share on other sites More sharing options...
0 jamend Posted December 2, 2007 Share Posted December 2, 2007 tinytext/text? Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589030468 Share on other sites More sharing options...
0 Cailin Posted December 2, 2007 Share Posted December 2, 2007 If it's just plain text, then TEXT, otherwise, BLOB (for binary data). Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589030772 Share on other sites More sharing options...
0 FiREFLi Posted December 2, 2007 Author Share Posted December 2, 2007 And what does TEXT do that a VARCHAR or CHAR doesn't? Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589031194 Share on other sites More sharing options...
0 voidpharoh Posted December 2, 2007 Share Posted December 2, 2007 The maximum length for char/varchar in MySQL is 255 characters I believe. Whereas, text/blob has a much higher maximum character length available. Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589031210 Share on other sites More sharing options...
0 kyosuken Posted December 2, 2007 Share Posted December 2, 2007 varchar has been changed to allow 64k characters in mysql 5 if i am not wrong :) Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589031569 Share on other sites More sharing options...
0 FiREFLi Posted December 3, 2007 Author Share Posted December 3, 2007 Does either have a variable size which increases as the amount of data increases? Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589032950 Share on other sites More sharing options...
0 +mrbester MVC Posted December 3, 2007 MVC Share Posted December 3, 2007 If the datatypes are anything like SQL Server ones then: char is fixed size, meaning it will pad with spaces should the content length be less than the field size. varchar is variable length (hint: var at the beginning ;) ); it contains a pointer to the data rather than the data itself. How unknown is "unknown length"? Is it likely to be in the order of gigabytes, megabytes, kilobytes? If kilobytes or less then varchar is the best, otherwise go for text. If it isn't text in the first place, then BLOB. Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589033643 Share on other sites More sharing options...
0 Josh Posted December 3, 2007 Share Posted December 3, 2007 mrbester said: If the datatypes are anything like SQL Server ones then:char is fixed size, meaning it will pad with spaces should the content length be less than the field size. varchar is variable length (hint: var at the beginning ;) ); it contains a pointer to the data rather than the data itself. How unknown is "unknown length"? Is it likely to be in the order of gigabytes, megabytes, kilobytes? If kilobytes or less then varchar is the best, otherwise go for text. If it isn't text in the first place, then BLOB. And if it's an "unknown file size" greater than 64kb then you're going to need to use mediumblob (holds up to 16MB) or largeblob(holds up to 4GB) instead. Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589034218 Share on other sites More sharing options...
0 Cailin Posted December 5, 2007 Share Posted December 5, 2007 Quote And if it's an "unknown file size" greater than 64kb then you're going to need to use mediumblob (holds up to 16MB) or largeblob(holds up to 4GB) instead. And this doesn't mean that each row will take up 64kb/16MB/4GB, but it does mean that there is an upper bound on the data size. The size of the row will increase dynamically as you insert larger data. Link to comment https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/#findComment-589037157 Share on other sites More sharing options...
Question
FiREFLi
What's best? I think most data types have specific limits don't they? Which one most efficiently scales up/down?
Link to comment
https://www.neowin.net/forum/topic/604290-mysql-best-field-type-to-use-for-unknown-length-data/Share on other sites
9 answers to this question
Recommended Posts