呵呵,用octet_length()来判断长度吧!和length()的区别是:length() -- 不包括尾部空格octet_length() -- 包括尾部空格例:create table aa(v varchar);Command completed successfully, 0 rows affected.insert into aa values('aaa');Command completed successfully, 1 rows affected.insert into aa values('bbb ');Command completed successfully, 1 rows affected.commit work;Command completed successfully, 0 rows affected.select * from aa;V-aaabbb2 rows fetched.select length(v), v from aa;LENGTH(V) V--------- -
3 aaa
3 bbb2 rows fetched.select octet_length(v), v from aa;OCTET_LENGTH(V) V--------------- -
3 aaa
4 bbb2 rows fetched. |