All Products
Search
Document Center

MaxCompute:BASE64

Last Updated:Mar 26, 2026

Converts a binary value into a Base64-encoded string.

Syntax

string base64(binary <value>)

Parameters

Parameter Required Type Description
value Yes BINARY The binary value to encode.

Return value

Returns a STRING value. If value is null, returns null.

Examples

Example 1: Encode a BINARY value using CAST.

-- Returns: YWxpYmFiYQ==
SELECT base64(CAST('alibaba' AS BINARY));

Example 2: Input is null.

-- Returns: null
SELECT base64(NULL);

Related functions

Other functions