The LPAD function left-pads the c1 string with the c2 string until the length reaches n.
Syntax
LPAD(c1,n[,c2])
Parameters
| Parameter | Description |
|---|---|
| c1 | The string. The string type can be CHAR, VARCHAR2, NCHAR, NVARCHAR2, or CLOB. |
| n | The total length of characters after the string is padded. The type must be the NUMBER integer type or the type that can be implicitly converted to the NUMBER integer type. |
| c2 | The padding string. The default value is a space. The string type can be CHAR, VARCHAR2, NCHAR, NVARCHAR2, or CLOB. |
Return type
If c1 is the data of the character type, the return type is VARCHAR2. If c1 is of the national character data type, the return type is NVARCHAR2. If the data type of c1 is CLOB, the return type is CLOB. Notice
If the length of c1 is greater than n, the function returns the leftmost n characters of c1. If the length of c1 is less than n and the length of c1 that is left-padded with c2 is greater than n, the function returns the rightmost n characters of c1 that is left-padded with c2.
Examples
Execute the following statement:
SELECT lpad('gao',10,'*') FROM DUAL;
The following query result is returned:
+--------------------+
| LPAD('GAO',10,'*') |
+--------------------+
| *******gao |
+--------------------+