TO_BASE64
Descriptionβ
The TO_BASE64 function is used to convert an input string to Base64 encoded format. Base64 encoding can convert any binary data into a string composed of 64 characters.
Syntaxβ
TO_BASE64(<str>)
Parametersβ
Parameter | Description |
---|---|
<str> | The string to be Base64 encoded. Type: VARCHAR |
Return Valueβ
Returns VARCHAR type, representing the Base64 encoded string.
Special cases:
- If input is NULL, returns NULL
- If input is an empty string, returns an empty string
Examplesβ
- Single character encoding
SELECT to_base64('1');
+----------------+
| to_base64('1') |
+----------------+
| MQ== |
+----------------+
- Multiple character encoding
SELECT to_base64('234');
+------------------+
| to_base64('234') |
+------------------+
| MjM0 |
+------------------+