See two of the functions that have not been seen in SQL today, summarize;
Function parameters:lpad (string1, padded_length, [pad_string])
which
String1: source string
Padded_length: The length of the string returned by the final result, and if the length of the final returned string is smaller than the source string, then this function actually intercepts the source strings, exactly as substr (String,number1,number2) does. If the padded_length is longer than the length of the source string, it is populated with pad_string, ensuring that the length of the final string returned is padded_length;
Pad_string: The character used for padding, can not be filled, default is null character
Instance:
Select lpad ('123456',2 from dual- Results A
Select lpad ('123456',7,'0' from dual-- result is 0123456
--note that in the left padding Lpad L is left, meaning
select rpad ( " 123456 ", 2 , " 0 ") from dual --
Select rpad ('123456',7,'0' from Dual -- result is 1234560
--rpad padding on the right, R to right
Summarize:
As you can see, when the length of the string1 source string is less than padded_length, the function of Lpad and Rpad is the same, which is equivalent to the substr intercept string, when Padded_length is greater than the length of the string1 source string, Lpad to fill the left side of the source string with the specified character or space, rpad to the right of the source string to fill the specified character or space;
How to use Lpad and RPAD functions in Oracle (plus personal Summary)