Text & patterns
Scalar
encode()
Converts the string to BLOB. Converts UTF-8 characters into literal encoding.
Arguments & returns
encode(string)
Scalar
| Overload link | string |
Returns |
|---|---|---|
| #01 | VARCHAR |
BLOB |
Example
Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
In other engines
Used in larger rewrites 1
These examples use encode as one part of a larger SQL translation.
Snowflakeuuid_string()
UUID_STRING('fe971b24-9572-4005-b22f-351e9c09274d', 'foo')
(SELECT LOWER(SUBSTRING(h, 1, 8) || '-' || SUBSTRING(h, 9, 4) || '-' || '5' || SUBSTRING(h, 14, 3) || '-' || FORMAT('{:02x}', CAST('0x' || SUBSTRING(h, 17, 2) AS INT) & 63 | 128) || SUBSTRING(h, 19, 2) || '-' || SUBSTRING(h, 21, 12)) FROM (SELECT SUBSTRING(SHA1(UNHEX(REPLACE('fe971b24-9572-4005-b22f-351e9c09274d', '-', '')) || ENCODE('foo')), 1, 32) AS h))