VeloDB Cloud
SQL Reference
SQL Functions
Scalar Functions
String Functions
TO_BASE64

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

ParameterDescription
<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

  1. Single character encoding
SELECT to_base64('1');
+----------------+
| to_base64('1') |
+----------------+
| MQ==           |
+----------------+
  1. Multiple character encoding
SELECT to_base64('234');
+------------------+
| to_base64('234') |
+------------------+
| MjM0             |
+------------------+