Lpad 1. Grammar lpad (STRING,PAD_LENGTH,[PAD_STR])
2. Explanation
The function represents the padding of the specified character from the left of the string to the specified length. The space of the string is also counted into the length.
String Pad_length: The length of the string to be populated, and if the value is smaller than the length of the original string, the string after that length that is intercepted from the left of the string is returned. PAD_STR: The string to be populated, an optional function, or, if there is no value, padding the left with a space.
Example 1:select lpad (' abc ', ' 5 ', ' @ ') from dual; --------------------@ @abc Example 2:select lpad (' ABCDEFG ', ' 5 ', ' @ ') from dual; -----------------------ABCDE Example 3:select lpad (' ab CDEFG ', ' 5 ', ' @ ') from dual; -----------------------AB CD example 4:select lpad (' abc ', ' 5 ') from dual; ---------------ABC
Rpad:
1. Syntax: Rpad(String,pad_length,[pad_str])
2. Explanation
The function represents the padding of the specified character from the right of the string to the specified length. The space of the string is also counted into the length.
String Pad_length: The length of the string to be populated, and if the value is smaller than the length of the original string, the string after that length that is intercepted from the left of the string is returned. PAD_STR: The string to be populated, an optional function, or, if there is no value, padding the right with a space.
Example 1:select rpad (' abc ', ' 5 ', ' # ') from dual; -------------------abc##
Example 2:select rpad (' ab C ', ' 5 ', ' # ') from dual; -------------------AB C #
Example 3:select rpad (' abc ', ' 2 ', ' # ') from dual; -------------------AB
Example 4:select rpad (' abc ', ' 2 ', ' # ') from dual; -------------------A
Use of the Fill function lpad/rpad in Oracle