Use of the Fill function lpad/rpad in Oracle

Source: Internet
Author: User


Lpad 1. Grammar lpad (STRING,PAD_LENGTH,[PAD_STR])
2. Explanation
The function represents the padding of the specified character from the left of the string to the specified length. The space of the string is also counted into the length.
String Pad_length: The length of the string to be populated, and if the value is smaller than the length of the original string, the string after that length that is intercepted from the left of the string is returned. PAD_STR: The string to be populated, an optional function, or, if there is no value, padding the left with a space.
Example 1:select lpad (' abc ', ' 5 ', ' @ ') from dual;    --------------------@ @abc Example 2:select lpad (' ABCDEFG ', ' 5 ', ' @ ') from dual;    -----------------------ABCDE Example 3:select lpad (' ab CDEFG ', ' 5 ', ' @ ') from dual;    -----------------------AB CD example 4:select lpad (' abc ', ' 5 ') from dual; ---------------ABC

Rpad:
1. Syntax: Rpad(String,pad_length,[pad_str])
2. Explanation
The function represents the padding of the specified character from the right of the string to the specified length. The space of the string is also counted into the length.
String Pad_length: The length of the string to be populated, and if the value is smaller than the length of the original string, the string after that length that is intercepted from the left of the string is returned. PAD_STR: The string to be populated, an optional function, or, if there is no value, padding the right with a space.
Example 1:select rpad (' abc ', ' 5 ', ' # ') from dual; -------------------abc##
Example 2:select rpad (' ab C ', ' 5 ', ' # ') from dual; -------------------AB C #
Example 3:select rpad (' abc ', ' 2 ', ' # ') from dual; -------------------AB
Example 4:select rpad (' abc ', ' 2 ', ' # ') from dual; -------------------A






Use of the Fill function lpad/rpad in Oracle

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.