VeloDB Cloud
SQL Reference
SQL Functions
Scalar Functions
String Functions
RPAD

RPAD

Description

Used to pad the specified character on the right side of the original string until met the specified length.

Syntax

RPAD ( <str> , <len> , <pad>)

Parameters

ParameterDescription
<str>The string to be padded.
<len>The total length of the final result string, which represents character length rather than the byte length.
<pad>The string used for padding.

Return Value

Returns the padded string. Special cases:

  • If any Parameter is NULL, NULL will be returned.
  • If <pad> is empty and <len> is greater than the length of <str>, the return value is an empty string.
  • If <len> is less than the length of <str>, the string obtained by truncating <str> to <len> is returned.
  • If <len> is less than 0, the return value is NULL.

Examples

SELECT rpad('hello', 1, '');
+----------------------+
| rpad('hello', 1, '') |
+----------------------+
| h                    |
+----------------------+
SELECT rpad('hello', 10, 'world');
+----------------------------+
| rpad('hello', 10, 'world') |
+----------------------------+
| helloworld                 |
+----------------------------+
SELECT rpad('hello', 10, '');
+-----------------------+
| rpad('hello', 10, '') |
+-----------------------+
|                       |
+-----------------------+