LPAD

2023-07-28 02:53:17  Updated

Syntax

LPAD(str,len,padstr)

Purpose

LPAD() left-pads the str string with the padstr string to a length of len characters.

If the length of str exceeds len, the leftmost len characters of str are returned. If the length of str is less than len, and the total length of str and padstr is greater than len, then the rightmost len characters in the resulting string are returned.

Examples

obclient> SELECT LPAD('Base',9,'Ocean');
+------------------------+
| LPAD('Base',9,'Ocean') |
+------------------------+
| OceanBase              |
+------------------------+
1 row in set

obclient> SELECT LPAD('Base',1,'Ocean');
+------------------------+
| LPAD('Base',1,'Ocean') |
+------------------------+
| B                      |
+------------------------+
1 row in set

Contact Us