I only get set the text field in MySQL to 255, if I want to store a data longer than 255 chars, what can I do?
Until v5.0.3, a varchar could only be up to 255 chars. From 5.0.3 onwards, you can have up to 65535 chars, same as a TEXT column. To go larger, you need MEDIUMTEXT (2^24 bytes) or LONGTEXT (2^32 bytes)
Paul Dixon
2009-09-25 12:42:13
+3
A:
Use TEXT
datatype:
CREATE TABLE t_text (value TEXT NOT NULL);
INSERT
INTO t_text
SELECT RPAD('', 1000, '*');
SELECT LENGTH(value)
FROM t_text;
---
1000
Quassnoi
2009-09-25 12:22:05
+8
A:
Prior to MySQL 5.0.3, a VARCHAR could only store up to 255 characters.
- To store up to 65535 (64KB) characters, use a TEXT column.
- To store up to 16777216 (16MB ) characters, use a MEDIUMTEXT column.
- To store up to 4294967296 (4GB) characters, use a LONGTEXT column.
See the storage requirements section of the manual for caveats on their usage.
Versions of MySQL after 5.0.3 can store up to 65535 chars in a VARCHAR (However you cannot store more than 65535 bytes in a single row).
Paul Dixon
2009-09-25 12:45:55
A:
MySQL 4.0 -- Maximum length storage (Bytes) for String types: CHAR(255); VARCHAR(255); TINYBLOB, TINYTEXT < 2^8; BLOB, TEXT < 2^16; MEDIUMBLOB, MEDIUMTEXT < 2^24; LONGBLOB, LONGTEXT < 2^32;
gerard
2009-09-25 12:55:13