April 3rd, 2000, 11:46 AM
Hi, im working with perl and dbi.
Is there any select clause i can use to get the size of a field in bytes?
Tnx in advance.
April 6th, 2000, 05:50 PM
The byte size of a field generally depends upon the datatype of the column which you can find out with
SHOW COLUMNS FROM tbl_tablename;
1 byte: TINYINT, YEAR
2 bytes: SMALLINT
3 bytes: MEDIUMINT, TIME, DATE
4 bytes: INT, TIMESTAMP,FLOAT etc.
string types are one byte per character plus one byte for the terminator (unless it's a multibyte character set).
SELECT LENGTH (string);
returns the number of characters.