SQLite
length()函数返回给定的字符串的字符数量,或者返回给定 blob 值的字节数量。
length()
语法
这里是 SQLite
length()函数的语法:
length(x)
参数
x必需的。 一个字符串或者 blob 值。
返回值
SQLite
length()函数返回一个整数值。对于字符串参数来说,
length()返回的是字符串中的字符数量;对于 blob 参数来说,
length()返回的是 blob 中的字节数量。
length()
实例
要获取字符串
hello的字符数量,请使用如下带有
length()函数的语句:
SELECT length('hello'); length('hello')---------------5SQLite
length()函数支持多字节的文字,比如要获取字符串
你好的字符数量,请使用如下带有
length()函数的语句:
SELECT length('你好'); length('你好')------------2对于 blob 参数来说,
length()返回的是 blob 中的字节数量。 比如:
SELECT length(cast('你好' AS blob)); length(cast('你好' AS blob))--------------------------6