Oracle lpad functions:
Copyright Notice: Mark the reprinted object with a hyperlinkArticleOriginal Source and author information andThis statement
Http://soysky.blogbus.com/logs/43623642.html
The Oracle lpad function fills the string on the left with some specific characters. The syntax format is as follows:
Lpad (string1, padded_length [, pad_string])
Where:
String1 is the string to be pasted;
Padded_length is the number of returned strings. If the number is shorter than the length of the original string, the lpad function splits the string into padded_length. pad_string is an optional parameter, this string is to be pasted to the left of string1. If this parameter is not written, the lpad function will paste a space on the left of string1.
For example:
Lpad ('tech ', 7); will return 'tech'
Lpad ('tech ', 2); will return 'te'
Lpad ('tech ', 8, '0'); will return 'technical tech'
Lpad ('tech on the net', 15, 'z'); will return 'tech on the net'
Lpad ('tech on the net', 16, 'z'); returns 'ztech on the net'
Lpad (str1, number, str2), which simply means that if str1 is less than number, then use str2 to fill the left blank
Eg:
Select lpad ('***', 6, 'orcal') from dual
-- Result
ORC ***