Oracle / PLSQL: RPAD Function

This article is written about how to use the Oracle/PLSQL RPAD feature with syntax and examples.

Description

The Oracle/PLSQL RPAD function pads the right-side of a string with a unique set of characters (when string1 is now 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 authentic string, the RPAD characteristic will truncate the string to the dimension 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 feature will pad spaces to the right-side of string1.

Returns

The RPAD function returns a string value.

Applies To

The RPAD characteristic 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 feature examples and discover how to use the RPAD characteristic in Oracle/PLSQL.

For example:

RPAD('tech', 7)
Result: 'tech   '

RPAD('tech', 2)
Result: 'te'

RPAD('tech', 8, '0')
Result: 'tech0000'

RPAD('tech on the net', 15, 'z')
Result: 'tech on the net'

RPAD('tech on the net', 16, 'z')
Result: 'tech on the netz'