16.2. String Data TypesString data types store various kinds of text data. There are several types to accomodate data of different sizes. For each size, there is a type that sorts and compares entries in a case-insensitive fashion in accordance with the sorting rules for the default character set and a corresponding binary type that does simple byte-by-byte sorts and comparisons. In other words, binary values are case sensitive. For CHAR and VARCHAR, the binary types are declared using the BINARY attribute. The TEXT types, however, have corresponding BLOB types as their binary counterparts.
SyntaxCHAR(size) [BINARY] SizeSpecified by the size value in a range of to 255 (1 to 255 prior to MySQL 3.23) Storagesize bytes DescriptionA fixed-length text field. String values with fewer characters than the column's size will be right padded with spaces. The right padding is removed on retrieval of the value from the database. CHAR(0) fields are useful for backward compatibility with legacy systems that no longer store values in the column.
Synonym for CHAR.
Synonym for VARCHAR.
SyntaxLONGTEXT Size0 to 4,294,967,295 StorageLength of value + 4 bytes DescriptionStorage for large text values. While the theoretical limit on the size of the text that can be stored in a LONGTEXT column exceeds 4 GB, the practical limit is much less due to limitations of the MySQL communication protocol and the amount of memory available on both the client and server ends of the communication.
SyntaxMEDIUMTEXT Size0 to 16,777,215 StorageLength of value + 3 bytes DescriptionStorage for medium-sized text values.
Synonym of CHAR.
Synonym of CHAR.
Synonym of VARCHAR.
SyntaxTEXT Size0 to 65,535 StorageLength of value + 2 bytes DescriptionStorage for most text values.
SyntaxTINYTEXT Size0 to 255 StorageLength of value + 1 byte DescriptionStorage for short text values.
SyntaxVARCHAR(size) [BINARY] SizeSpecified by the size value in a range of to 255 (1 to 255 prior to MySQL 3.23) StorageLength of value + 1 byte DescriptionStorage for variable-length text. Trailing spaces are removed from VARCHAR values when stored in a database that conflicts with the ANSI specification. Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|