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 ********** . . .
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework