Updated on 2026-11-06 GMT+08:00

repeat

The repeat function is used to return a string consisting of str repeated n times.

Syntax

repeat(string , bigint ) 

Parameters

Parameter

Mandatory

Type

Description

str

Yes

STRING

The string to be repeated. If the input is of type BIGINT, DOUBLE, DECIMAL, or DATETIME, it is implicitly converted to STRING type before evaluation.

n

Yes

BIGINT

The number of repetitions.

Return Values

Returns STRING type.

  • If str is not of type STRING, BIGINT, DOUBLE, DECIMAL, or DATETIME, an error is returned.
  • If n is empty, an error is reported.
  • If str or n is NULL, NULL is returned.

Example Code

Repeat the string 123 2 times. Return 123123.

SELECT repeat('123', 2);