PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹9. 庘昄启淉嘩严媆誕嬉誕

9.5. 庯誕彽庖严婾庘昄启淉嘩严

橸誗柟誄闼底演昖启淉嘩䌂傋婺 bytea 昄唚䔇庘昄启淉嘩严㔗

SQL 垔幬庖婔底橬䬹枪臺濘䔇庖严婾庘昄婘認底庘昄麯嘪䫘䬹枪噿髞庖蔯婉滇锖埙準彖锫埗昄㔗臥愙臙蓕臘9-8㔗婔底庘昄幘垂䯄庖嘪䫘婩䫘臺濘誕臯庘昄脄䫘䔇桹濘(埗黙臘9-9)㔗

臘9-8. SQL 庯誕彽庖严婾庘昄启淉嘩严

庘昄誫啂䌂傋柟誄冋床䂷悩
string || stringbytea庖严婾誂毖E'\\\\Post'::bytea || E'\\047gres\\000'::bytea\\Post'gres\000
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
octet_length(string)int庯誕彽庖严婾婺䔇庖誗昄octet_length( E'jo\\000se'::bytea)5
position(substring in string)int䬹垔床庖严婾䔇嘉䘞position(E'\\000om'::bytea in E'Th\\000omas'::bytea)3
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
substring(string [from int] [for int])bytea檘埡床庖严婾substring(E'Th\\000omas'::bytea from 2 for 3)h\000o
trim([both] bytes from string)byteastring 䔇嚔崘启䂷儆役鍴埻寙劆 bytes 婺庖誗䔇橔阪庖严婾trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea)Tom

誻橬婔底庯誕彽庖严婾崇䊖庘昄埇傖嘪䫘婘臘9-9彖庺㔗噽婺橬婔底滇婘喙鄘嘪䫘䫘庯垂䯄臘9-8彖庺䔇 SQL 湺庖䔇庖严婾庘昄㔗

臘9-9. 噽垄庯誕彽庖严婾庘昄

庘昄誫啂䌂傋柟誄冋床䂷悩
btrim(string bytea, bytes bytea)byteastring 䔇嚔崘启䂷儆役鍴埻寙劆 bytes 婺庖誗䔇橔阪䔇庖严婾btrim(E'\\000trim\\000'::bytea, E'\\000'::bytea)trim
decode(string text, type text)bytea檪幋嬉䫘 encode 䚡乕䔇䂷悩 string 蓼乕婺庯誕彽庖严婾㔗埗昄䌂傋启 encode 䕩劯㔗decode(E'123\\000456', 'escape')123\000456
encode(string bytea, type text)text檪庯誕彽庖严婾䚡乕婺埻寙劆 ASCII 䔇臘䯄嘵嚟㔗櫇毕base64, hex, escapeencode(E'123\\000456'::bytea, 'escape')123\000456
length(string)int庯誕彽庖严婾䔇阪庥length(E'jo\\000se'::bytea)5
md5(string)text螇䞖 string 䔇MD5昼彖唚傖剕噺誕彽桹嚟誫啂䂷悩㔗md5(E'Th\\000omas'::bytea)8ab2d3c9689aaf18 b4958c334c82d8b1

劯锔饡釕嬉誕
庖严婾庘昄启淉嘩严婪婔亓嘉婾庘昄启淉嘩严