• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql
You are here: Home / Oracle / function / Oracle PL/SQL RPAD Function

Oracle PL/SQL RPAD Function

November 26, 2012 by techhoneyadmin

Oracle PLSQL RPAD FunctionOracle RPAD Function is used to pad a string with a set of characters from the right-side. SQL RPAD Function can not only pad a string with spaces but also with characters supplied as arguments. Syntax and examples of PLSQL RPAD Function are mentioned below.


Oracle RPAD Function Syntax

SELECT RPAD(string_1,padded_length[,padding_string])
FROM table_name;

In the above PLSQL RPAD Function Syntax:-

  • string_1 is the string which will be padded from the right side. The string_1 should not be NULL.
  • padded_length is the number of characters in return, if the padded_length is smaller than string_1, then RPAD function will pad spaces to the right side of string_1.

Oracle RPAD Function – Use with SQL SELECT Statement Example

SQL RPAD Function is used with the SQL SELECT Statement.

For example, the PLSQL RPAD Function query below returns string padded with spaces on the right side.

SELECT RPAD('Tech', 7)
FROM dual;

The above PLSQL RPAD Function query returns ‘Tech ‘.


Oracle RPAD Function – Padding with Spaces Example

SQL RPAD Function can pad a string with white spaces on the right side.

For example, the SQL RPAD Function query below returns string padded with spaces on the right side.

SELECT RPAD('Tech', 7)
FROM dual;

The above SQL RPAD Function query returns ‘Tech ‘.


Oracle RPAD Function – Padding with Characters Example

SQL RPAD Function can also pad a string with any character.

For example, the SQL RPAD Function query below returns the string padded witg ‘-‘ on the right side.

SELECT RPAD('Honey', 8, '-')
FROM dual;

The above SQL RPAD Function query returns ‘Honey- – -‘


Oracle RPAD Function – Using Exact Length of String Example

If we try to pad a string with the same length as that of the string, then the Oracle RPAD Function returns the string.

For example, the SQL RPAD Function query below tries to pad a string of length 10.

SELECT RPAD('Tech Honey', 10, '-')
FROM dual;

The above SQL RPAD Function query returns ‘Tech Honey’.

Notice that there is no change in passed and returned string as there was no scope of padding for SQL RPAD Function.


Filed Under: function Tagged With: how to use RPAD Function in oracle database query, how to use RPAD Function in oracle plsql, how to use RPAD Function in oracle sql, RPAD Function in oracle plsql, RPAD Function in oracle sql, RPADPLSQL, syntax and example of RPAD Function in oracle database query, syntax and example of RPAD Function in oracle plsql, syntax and example of RPAD Function in oracle sql, using RPAD Function in oracle database query, using RPAD Function in oracle plsql, using RPAD Function in oracle sql

Copyright © 2023 · Parallax Pro on Genesis Framework · WordPress · Log in