Oracle Plsql Rpad Function

Oracle / PLSQL: RPAD Function

This Oracle tutorial explains how to use the Oracle/PLSQL RPAD function with syntax and examples.

Description

The Oracle/PLSQL RPAD function pads the right-side of a string with a specific set of characters (when string1 is not null).

Syntax

The syntax for the RPAD function in Oracle/PLSQL is:

RPAD( string1, padded_length [, pad_string] )

Parameters or Arguments

string1

The string to pad characters to (the right-hand side).

padded_length

The number of characters to return. If the padded_length is smaller than the original string, the RPAD function will truncate the string to the size of padded_length.

pad_string

Optional. This is the string that will be padded to the right-hand side of string1. If this parameter is omitted, the RPAD function will pad spaces to the right-side of string1.

Returns

The RPAD function returns a string value.

Applies To

The RPAD function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let's look at some Oracle RPAD function examples and explore how to use the RPAD function in Oracle/PLSQL.

For example:

RPAD('aodb', 7)
Output: 'aodb '

RPAD('aodb', 2)
Output: 'te'

RPAD('aodb', 8, '0')
Output: 'aodb0000'

RPAD('aodb in the bol', 15, 'z')
Output: 'aodb in the bol'

RPAD('aodb in the bols', 16, 's')
Output: 'aodb in the bols'