get_byte() 是一个用于从二进制字符串中提取指定字节的系统函数。
get_byte() 添加于 PostgreSQL 7.0。
用法
get_byte (bytesbytea,ninteger) →integer
变更历史
- PostgreSQL 7.0
- 添加 (提交 eca02fee)
请注意,在早期版本中 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
参考资料
- PostgreSQL 文档: 其他二进制字符串函数
另请参阅
反馈
“get_byte()”的任何评论、建议或更正请在此处提交。