9.5. 位元字串函式及運算子
This section describes functions and operators for examining and manipulating values of typebytea
.
SQLdefines some string functions that use key words, rather than commas, to separate arguments. Details are inTable 9.11.PostgreSQLalso provides versions of these functions that use the regular function invocation syntax (seeTable 9.12).
Note
The sample results shown on this page assume that the server parameterbytea_output
is set toescape
(the traditional PostgreSQL format).
Table 9.11. SQLBinary String Functions and Operators
Function | Return Type | Description | Example | Result | ||||
|
|
| String concatenation | `E'\\Post'::bytea | E'\047gres\000'::bytea` |
| ||
|
| Number of bytes in binary string |
|
| ||||
|
| Replace substring |
|
| ||||
|
| Location of specified substring |
|
| ||||
|
| Extract substring |
|
| ||||
|
| Remove the longest string containing only bytes appearing in |
|
|
Additional binary string manipulation functions are available and are listed inTable 9.12. Some of them are used internally to implement theSQL-standard string functions listed inTable 9.11.
Table 9.12. Other Binary String Functions
Function | Return Type | Description | Example | Result |
|
| Remove the longest string containing only bytes appearing in |
|
|
|
| Decode binary data from textual representation in |
|
|
|
| Encode binary data into a textual representation. Supported formats are: |
|
|
|
| Extract bit from string |
|
|
|
| Extract byte from string |
|
|
|
| Length of binary string |
|
|
|
| Calculates the MD5 hash of |
|
|
|
| Set bit in string |
|
|
|
| Set byte in string |
|
|
get_byte
andset_byte
number the first byte of a binary string as byte 0.get_bit
andset_bit
number bits from the right within each byte; for example bit 0 is the least significant bit of the first byte, and bit 15 is the most significant bit of the second byte.
See also the aggregate functionstring_agg
inSection 9.20and the large object functions inSection 34.4.
Last updated