All Products
Search
Document Center

RPAD

Last Updated: Jun 18, 2021

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 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 right-padded with c2 is greater than n, the function returns the leftmost n characters of c1 that is right-padded with c2.

  • If the length of c1 is less than n and the length of the c1 that is right-padded with c2 is also less than n, the function returns the leftmost n characters of c1 that is right-padded with multiple replicated c2 (the total length of c1 after padding is greater than or equal to n).

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*          |
+---------------------+