Syntax
RPAD(str,len,padstr)
Purpose
You can call this function to right-pad the str string with the padstr string to a length of len characters.
If the length of
strexceedslen, then the leftmostlencharacters ofstrare returned.If the length of
stris less thanlenbut the length ofstrright-padded withpadstris greater thanlen, then the leftmostlencharacters of the string generated after padding are returned.If the length of
stris less thanlenand the length ofstrright-padded withpadstris still less thanlen, thenstris right-padded with multiplepadstrstrings until the length is greater than or equal tolen, and the leftmostlencharacters of the string generated after padding are returned.
Examples
obclient> SELECT RPAD('hi',5,'?');
+------------------+
RPAD('hi',5,'?')
+------------------+
hi??? |
+------------------+
1 row in set (0.00 sec)
obclient> SELECT RPAD('hi',1,'?');
+------------------+
RPAD('hi',1,'?')
+------------------+
h
+------------------+
1 row in set (0.00 sec)