get_byte()

从二进制字符串中提取一个字节的函数

get_byte() 是一个用于从二进制字符串中提取指定字节的系统函数。

get_byte() 添加于 PostgreSQL 7.0

用法

get_byte ( bytes bytea, n integer ) → integer

变更历史

请注意,在早期版本中 get_byte()byteaGetByte() 的形式存在,但实现不正确。

示例

get_byte() 的基本用法示例

postgres=# SELECT to_hex(get_byte('\xdeadbeef', 1));
 to_hex
--------
 ad
(1 row)

如果提供的字节索引值超出所提供字符串的范围,则会引发一个错误。

postgres=# SELECT get_byte('\x42', 2);
ERROR:  index 2 out of valid range, 0..0

分类

bytea, 字符串操作, 系统函数

另请参阅

set_byte(), get_bit()

反馈

get_byte()”的任何评论、建议或更正请在此处提交。