octet_length()

返回给定参数字节数的函数

octet_length() 是一个系统函数,它返回给定参数中的字节数(八位字节)。

octet_length()PostgreSQL 6.4 中添加。

用法

octet_length ( text ) → integer
octet_length ( bytea ) → integer
octet_length ( bit ) → integer

变更历史

示例

使用 octet_length() 获取简单 ASCII 字符串中的字节数

postgres=# SELECT octet_length('ABC');
 octet_length 
--------------
            3
(1 row)

使用 octet_length() 获取包含多字节字符的 UTF8 字符串中的字节数

postgres=# SELECT octet_length('ほげほげ');
 octet_length 
--------------
           12
(1 row)

使用 octet_length() 获取二进制字符串中的字节数

postgres=# SELECT octet_length('\xdeadbeef'::bytea);
 octet_length 
--------------
            4
(1 row)

分类

bytea, 系统函数

另请参阅

bit_length(), length()

反馈

提交有关“octet_length()”的任何评论、建议或更正,请点击此处