Lpad & rpad

Source: Internet
Author: User

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

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.