solidDB判断字符串长度

来源:百度知道 编辑:UC知道 时间:2024/06/16 06:50:28
如果判断尾部带有空格的字符串

呵呵,用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
-
aaa
bbb
2 rows fetched.

select length(v), v from aa;
LENGTH(V) V
--------- -
3 aaa
3 bbb
2 rows fetched.

select octet_length(v), v from aa;
OCTET_LENGTH(V) V
--------------- -
3 aaa
4 bbb
2 rows fetched.