Original link: http://blog.csdn.net/myzhanglt/article/details/7392999
Today's study encountered an unfamiliar function lpad, looked up the document, the usage summarized as follows:
Lpad Function: used in PL/SQL to fill some characters to the left of the source string.
Function parameters:lpad (string1, padded_length, [pad_string])
which
String1: source string
Padded_length: The length of the final returned string, if the length of the final returned string is smaller than the source string, then this function actually truncates the source strings
Pad_string: The character used for padding, can not be filled, default is null character
Here are a few examples:
eg
[SQL]
-- The return value is longer than the length of the source string and will be populated with select lpad ('zhanglt',ten,' z' from dual; The result is: zzzzhanglt-- The return value is less than the length of the source string and will be truncated by Select lpad ('ZHANGLT ',3,'z' from dual;
By default, spaces are populated.
The use of the RPAD function is basically consistent with the lpad, except that the fill direction is on the left, and one thing to note is that if the length is less than the source string, it is still truncated, and it starts with the first character on the left when truncated.
[zhanglt]@[20120325]
Usage of the Fill function Lpad and Rpad in Oracle (RPM)