Pad Characters on the Right Side of a String in Oracle

In Oracle, you can use the rpad() function to pad specific characters on the right side of a string in Oracle.

RPAD() Function Syntax

rpad(expr1, n, expr2)

The result of RPAD is expr1 plus an arbitrary number of repetitions of expr2 for right padding until it reaches length n characters. A query's results can be neatly formatted with the help of this function.

Padding Characters Right Side of a String in Oracle Example

The following SQL query pads the asterisks to the numeric value:

select rpad('8993.22', 10, '*') from dual;



Using RPAD() in PL/SQL Program

Below PL/SQL program, adds the dollar sign to the right side of a string using the rpad() function:

  v_string varchar2(100);
  v_string := rpad('Oracle', 15, '$');



See also:

Written by Rony Dsouza

Rony is an Oracle programmer, having more than 15 years of experience. He likes to write on SQL, PL/SQL, and Oracle Apex topics. Also, expertise in Python, PHP, MySQL, JavaScript, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *