Usage of the Fill function Lpad and Rpad in Oracle

Source: Internet
Author: User
Tags truncated

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)

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.