This Oracle tutorial explains how to use the Oracle/PLSQL LPAD function with syntax and examples.
The Oracle/PLSQL LPAD function pads the left-side of a string with a specific set of characters (when string1 is not null).
The syntax for the LPAD function in Oracle/PLSQL is:
LPAD( string1, padded_length [, pad_string] )
The string to pad characters to (the left-hand side).
The number of characters to return. If the padded_length is smaller than the original string, the LPAD function will truncate the string to the size of padded_length.
Optional. This is the string that will be padded to the left-hand side of string1. If this parameter is omitted, the LPAD function will pad spaces to the left-side of string1.
The LPAD function returns a string value.
The LPAD function can be used in the following versions of Oracle/PLSQL:
Let's look at some Oracle LPAD function examples and explore how to use the LPAD function in Oracle/PLSQL.
For example:
LPAD('aodb', 7);
Output: ' aodb'
LPAD('aodb', 2);
Output: 'te'
LPAD('aodb', 8, '0');
Output: '0000aodb'
LPAD('aodb on the net', 15, 'z');
Output: 'aodb on the net'
LPAD('aodb on the net', 16, 'z');
Output: 'zaodb on the net'