Oracle RPAD function
Description
The Oracle RPAD function is used to padding the right side of a string with a specific set of characters. This function is useful for formatting the output of a query.
The string cannot be null. If expr2 not specified then it defaults to a single blank. When expr1 is longer than n, then this function returns the portion of expr1 that fits in n.
Syntax:
RPAD(expr1 , n [, expr2 ])
Parameters:
Name | Description | Data Types |
---|---|---|
expr1 | Original string. | CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB |
n | A number indicating the total length of the string ( in characters) returned after padding. | NUMBER integer or a value that can be implicitly converted to a NUMBER integer. |
expr2 | String which is used for left padding. | CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB |
Return Value Type
CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB
Applies to
Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
Pictorial Presentation

Examples: Oracle RPAD function
The following example creates a simple chart of salary amounts by padding a single space with asterisks:
SELECT last_name, RPAD(' ', salary/1000/1, '*') "Salary"
FROM employees
WHERE department_id = 80
ORDER BY last_name, "Salary";
Sample Output:
LAST_NAME Salary ---------------------------------- Alberto *********** Allan ******** Alyssa ******* Amit ***** Charles ***** Christopher ******* Clara ********* Danielle ******** David ***** David ******** Eleni ********* Elizabeth ****** Ellen ********** . . .
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook