Binary Functions and Operators
- length(binary) → bigint
Return the byte length of binary.
select length(x'00141f');-- 3
- concat(binary1, ..., binaryN) → varbinary
Description: Concatenates binary1, binary2, and binaryN. This function returns the same function as the SQL standard connector ||.
select concat(X'32335F',x'00141f'); -- 32 33 5f 00 14 1f
- to_base64(binary) → varchar
Encodes binary to a Base64 character string.
select to_base64(CAST('hello world' as binary)); -- aGVsbG8gd29ybGQ=
- from_base64(string) → varbinary
Decode the Base64-encoded string as varbinary.
select from_base64('helloworld'); -- 85 e9 65 a3 0a 2b 95
- to_base64url(binary) → varchar
Use URL security characters to encode binary to a base64 character string.
select to_base64url(x'555555'); -- VVVV
- from_base64url(string) → varbinary
Use the URL security character to decode the Base64-encoded string into binary data.
select from_base64url('helloworld'); -- 85 e9 65 a3 0a 2b 95
- to_hex(binary) → varchar
Encode the binary to a hexadecimal string.
select to_hex(x'15245F'); -- 15245F
- from_hex(string) → varbinary
Decodes a hexadecimal string into binary data.
select from_hex('FFFF'); -- ff ff
- lpad(binary, size, padbinary) → varbinary
Description: Left-padded binary to adjust byte size using padbinary. If size is less than the length of the binary file, the result will be truncated to size characters. The value of size cannot be negative, and the value of padbinary cannot be empty.
select lpad(x'15245F', 11,x'15487F') ; -- 15 48 7f 15 48 7f 15 48 15 24 5f
- rpad(binary, size, padbinary) → varbinary
Description: Right-padded binary to use padbinary to resize bytes. If size is less than the length of the binary file, the result will be truncated to size characters. The value of size cannot be negative, and the value of padbinary cannot be empty.
SELECT rpad(x'15245F', 11,x'15487F'); -- 15 24 5f 15 48 7f 15 48 7f 15 48
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.