mysql的text欄位長度

軍說網事發表於2015-08-31

型別是可變長度的字串,最多65535個字元; 
   
可以把欄位型別改成MEDIUMTEXT(最多存放16777215個字元)或者LONGTEXT(最多存放4294967295個字元). 
MySQL supports 4 TEXT field types (TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT) andthis post looks at the maximum length of each of these field types. 
MyISAM tables in MySQL have a maximum size of a row of 65,535 bytes, so all thedata in a row must fit within that limit. However, the TEXT types are storedoutside the table itself and only contribute 9 to 12 bytes towards that limit.(For more information about this refer to the MySQL Manual - Data StorageRequirements chapter). TEXT data types are also able to store much more datathan VARCHAR and CHAR text types so TEXT types are what you need to use whenstoring web page or similar content in a database. The maximum amount of datathat can be stored in each data type is as follows: TINYTEXT 256 bytes  

TEXT 65,535 bytes ~64kb

MEDIUMTEXT 16,777,215 bytes ~16MB

LONGTEXT 4,294,967,295 bytes ~4GB

In most circumstancesthe TEXT type is probably sufficient, but if you are coding a contentmanagement system it's probably best to use the MEDIUMTEXT type for longerpages to ensure there are no issues with data size limits.




相關文章