tech on the net

Oracle/PLSQL: RPAD Function

Learn 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 Oracle/PLSQL RPAD function is:

RPAD( string1, padded_length, [ pad_string ] )

Parameters or Arguments

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

padded_length is 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 is 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.

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 you would use the RPAD function in Oracle/PLSQL.

For example:

RPAD('tech', 7); would return 'tech   '
RPAD('tech', 2); would return 'te'
RPAD('tech', 8, '0'); would return 'tech0000'
RPAD('tech on the net', 15, 'z'); would return 'tech on the net'
RPAD('tech on the net', 16, 'z'); would return 'tech on the netz'