Lpad (string, padded_length, [pad_string])
String:
Prepare the string to be filled
Padded_length:
String Length after filling
Pad_string:
Fill string, which is an optional parameter
Rpad: Fill from the right. The usage is the same as that of lpad.
1. lpad function: Oracle database function. It is used to fill in the specified string from the left.
Example 1: SQL> select lpad ('xxvvv ', 4) | 'aaa' | 'bbb' from dual;
Lpad ('xxvvv ', 4) | 'aaa' | 'bbb'
-----------------------------
Xxvvaaabbb
SQL> select lpad ('xxv', 4) | 'aaa' | 'bbb 'from dual;
Lpad ('xxv', 4) | 'aaa' | 'bbb'
---------------------------
Xxvaaabbb
Fill the string 'aaa' | 'bbb 'from the left. The filling length is 4 ('xxvvv' indicates the filling string, and 4 indicates the filling String Length, if the length of the string to be filled exceeds 4, the first four digits will be taken for filling. If the length cannot exceed 4, all digits will be filled)
Example 2: SQL> select lpad ('aaabbb', 10, 'x') from dual;
Lpad ('aaabbb', 10, 'x ')
---------------------
Xxxxaaabbb
Fill the 'aaabbb' string from the left ('aaabbb': the string to be filled, 10: the string length after filling, 'x': the string to be filled, the length of the filled string is 10)
Lpad & rpad