LPAD
LPAD(string1, n[, string2])

Pads the left side of string1 with spaces, or with copies of the character string specified by string2, until the size of the resulting string reaches n characters.

Parameters

string1

Specifies the string that you want padded.

n

Specifies the number of characters that you want in the result.

string2

Specifies the character sequence used to pad the input string to reach the desired length. This parameter defaults to a single space.

Example

SQL> SELECT LPAD('X',3), LPAD('X',3,'Y'), LPAD('RIGHT',12,'LEFT')
  2  FROM dual;

LPA LPA LPAD('RIGHT'
--- --- ------------
  X YYX LEFTLEFTRIGHT

Get Oracle SQL: the Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.