The RPAD function right-pads the c1 string with the c2 string until the length reaches n.
Syntax
RPAD(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. Note
If the length of
c1is greater thann, the function returns the leftmostncharacters ofc1.If the length of
c1is less thannand the length ofc1that is right-padded withc2is greater thann, the function returns the leftmostncharacters of c1 that is right-padded with c2.If the length of
c1is less than n and the length of thec1that is right-padded withc2is also less thann, the function returns the leftmostncharacters ofc1that is right-padded with multiple replicatedc2(the total length of c1 after padding is greater than or equal ton).
Examples
Execute the following statement:
SELECT rpad('gao',10,'*a') FROM DUAL;
The following query result is returned:
+---------------------+
| RPAD('GAO',10,'*A') |
+---------------------+
| gao*a*a*a* |
+---------------------+