RPAD()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a string right-padded with the specified characters.
USAGE
RPAD(string, width, padding)
Argument Name | Description |
---|---|
| The string to be padded |
| The desired width of the resulting string |
| The string that is used for padding |
DETAILS
RPAD()
is a string function that returns the string right-padded in a field of the specified width using the specified padding string.
A string that is longer than the specified width is shortened to fit within the width.
A string that is shorter than the specified width has the beginning of the field with filled in with the padding characters, which are repeated if they are shorter than the needed padding length.
A NULL
is returned if any argument is NULL
.
EXAMPLES
SELECT RPAD('Example', 15, ' .') AS result;
+-----------------+
| result |
+-----------------+
| Example . . . . |
+-----------------+
SELECT RPAD('Example', 2, '~') AS r;
+------+
| r |
+------+
| Ex |
+------+
SELECT RPAD('FOO', 42, '_.~"~._.~"~._.~"~._.~"~.') AS result;
+--------------------------------------------+
| result |
+--------------------------------------------+
| FOO_.~"~._.~"~._.~"~._.~"~._.~"~._.~"~._.~ |
+--------------------------------------------+