Oracle ipad function (padding from left) ___ static function
Source: Internet
Author: User
The syntax format is as follows:
Lpad (String, Padded_length, [pad_string])
String
Prepares the string to be filled;
Padded_length
The length of the string after the padding, which is the length of the string returned by the function, if the number is shorter than the length of the original string, the Lpad function will intercept the string into N characters from left to right;
Pad_string
The padding string, which is an optional argument, is pasted to the left of a string, and if this argument is not written, the Lpad function will paste a space on the left side of the string.
Example 1:
Sql> Select Lpad (' ABCDE ', ten, ' X ') from dual;
Lpad (' ABCDE ', ten, ' X ')
--------------------
Xxxxxabcde
Example 2:
Sql> Select Lpad (' ABCDE ', ten, ' OQ ') from dual;
Lpad (' ABCDE ', ten, ' OQ ')
---------------------
Oqoqoabcde
Example 3:
Sql> Select Lpad (' ABCDE ', 2) from dual;
Lpad (' ABCDE ', 2)
---------------
Ab
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
corresponding to the Lpad function is the Rpad function:
The Rpad function fills the string with the specified character from the right, with the same syntax as the LPAD format:
Rpad (string,padded_length,[pad_string])
String
The string being filled
Padded_length
The length of the character, the number of strings returned, if this number is shorter than the length of the original string, the Rpad function will intercept the string into N characters from left to right;
Pad_string
is an optional argument, the string is pasted to the right of the string, and if this argument is not written, the Lpad function will paste a space on the right side of the string.
For example:
Rpad (' Tech ', 7); will return to ' tech '
Rpad (' Tech ', 2); will return ' Te '
Rpad (' Tech ', 8, ' 0 '); will return to ' tech0000 '
Rpad (' Tech on the net ', ' Z '); Will return ' Tech on ' net '
Rpad (' Tech on the net ', ' Z '); Will return ' tech on the Netz '
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.