CREATE TABLE `test` ( `id` INT( 8 ) UNSIGNED NOT NULL AUTO_INCREMENT , 
 
`title` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , 
 
PRIMARY KEY ( `id` ) 
 

) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;


如果该表已经运行了很长时间,想察看该表中title字段存储的最长的值,以方便我们优化数据库,可使用如下语句来查询:
SELECT `id` , `title` ,char_length( trim(title) )  AS `len`
FROM `test`
ORDER BY `len` DESC LIMIT 10

然后根据已有数据的长度,通过缩短字符类型的字段的长度或改varchar 为char,对数据库进行优化 !