对二进制字符串的函数,运算,这个一般并不常用,用法也很类似与对String的操作。
Function |
Return Type |
Description |
Example |
Result |
string || string |
bytea |
字符串连接 |
E'\\\\Post'::bytea || E'\\047gres\\000'::bytea |
\\Post'gres\000 |
octet_length(string) |
int |
字符串长度 |
octet_length(E'jo\\000se'::bytea) |
5 |
overlay(string placingstring from int [forint]) |
bytea |
字符串替换 |
overlay(E'Th\\000omas'::bytea placing E'\\002\\003'::bytea from 2 for 3) |
T\\002\\003mas |
position(substring instring) |
int |
字符串定位 |
position(E'\\000om'::bytea in E'Th\\000omas'::bytea) |
3 |
substring(string [fromint] [for int]) |
bytea |
字符串截取 |
substring(E'Th\\000omas'::bytea from 2 for 3) |
h\000o |
trim([both] bytes fromstring) |
bytea |
字符串截取 |
trim(E'\\000\\001'::bytea from E'\\000Tom\\001'::bytea) |
Tom |
Function |
Return Type |
Description |
Example |
Result |
btrim(stringbytea, bytesbytea) |
bytea |
从字符串的开始、结束或两端(都是默认的),删除包含字符(默认为空格)的字符串。 |
btrim(E'\\000trim\\001'::bytea, E'\\000\\001'::bytea) |
trim |
decode(stringtext, formattext) |
bytea |
解码 |
decode(E'123\\000456', 'escape') |
123\000456 |
encode(databytea, formattext) |
text |
编码 |
encode(E'123\\000456'::bytea, 'escape') |
123\000456 |
get_bit(string,offset) |
int |
从字符串中取出位 |
get_bit(E'Th\\000omas'::bytea, 45) |
1 |
get_byte(string,offset) |
int |
从字符串中取出字节 |
get_byte(E'Th\\000omas'::bytea, 4) |
109 |
length(string) |
int |
取出二进制长度 |
length(E'jo\\000se'::bytea) |
5 |
md5(string) |
text |
算出MD5 |
md5(E'Th\\000omas'::bytea) |
8ab2d3c9689aaf18 b4958c334c82d8b1 |
set_bit(string,offset,newvalue) |
bytea |
将字符串转换为二进制后,改其中一位的值 |
set_bit(E'Th\\000omas'::bytea, 45, 0) |
Th\000omAs |
set_byte(string,offset,newvalue) |
bytea |
将字符串转换为字节后,改其中一位的值 |
set_byte(E'Th\\000omas'::bytea, 4, 64) |
Th\000o@as |