Skip to content

Returns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.

func.lpad(<str>, <len>, <padstr>)
func.lpad('hi',4,'??')
┌────────────────────────┐
│ func.lpad('hi',4,'??') │
├────────────────────────┤
??hi │
└────────────────────────┘
func.lpad('hi',1,'??')
┌────────────────────────┐
│ func.lpad('hi',1,'??') │
├────────────────────────┤
│ h │
└────────────────────────┘
LPAD(<str>, <len>, <padstr>)
ArgumentsDescription
<str>The string.
<len>The length.
<padstr>The pad string.

VARCHAR

SELECT LPAD('hi',4,'??');
┌─────────────────────┐
│ LPAD('hi', 4, '??') │
├─────────────────────┤
│ ??hi │
└─────────────────────┘
SELECT LPAD('hi',1,'??');
┌─────────────────────┐
│ LPAD('hi', 1, '??') │
├─────────────────────┤
│ h │
└─────────────────────┘