Oracle Lpad () function and Rpad () function usage

Source: Internet
Author: User

 

Lpad () function usage:

The lpad function fills the string on the left with some specific characters. The syntax format is as follows:

Lpad (string, n, [pad_string])

String: but a character or Parameter

N: the length of the character, which 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 n characters from left to right;

Pad_string: it is an optional parameter. This string is to be pasted to the left of the string. If this parameter is not written, the lpad function will paste a space on the left of the string.

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'

---------------------------------------------------------

Rpad () function usage:

The rpad function fills the string on the right with some specific characters. The syntax format is as follows:

Rpad (string, n, [pad_string])

String: but a character or Parameter

N: the length of the character, which 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 n characters from left to right;

Pad_string: it is an optional parameter. This string is to be pasted to the right of the string. If this parameter is not written, the lpad function will paste a space on the right of the string.

For example:

Rpad ('tech ', 7); will return 'tech'

Rpad ('tech ', 2); will return 'te'

Rpad ('tech ', 8, '0'); 'tech0000' will be returned'

Rpad ('tech on the net', 15, 'z'); will return 'tech on the net'

Rpad ('tech on the net', 16, 'z'); will return 'tech on the netz'

Progress in crawling

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.