Home > Database > Mysql Tutorial > lpad&rpad

lpad&rpad

WBOY
Release: 2016-06-07 16:05:00
Original
1691 people have browsed it

lpad( string, padded_length, [ pad_string ] ) string: 准备被填充的字符串 padded_length: 填充之后的字符串长度 pad_string: 填充字符串,是个可选参数 RPAD:从右边开始填充,用法同LPAD。 1、LPAD函数:oracle数据库函数,是从左边起对指定的字符串进

lpad( string, padded_length, [ pad_string ] )

string:
准备被填充的字符串
padded_length:
填充之后的字符串长度
pad_string:
填充字符串,是个可选参数

RPAD:从右边开始填充,用法同LPAD。

1、LPAD函数:oracle数据库函数,是从左边起对指定的字符串进行指定的字符填充。

实例一: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
从左边开始对字符串'AAA'||'BBB'进行填充,填充长度为4(‘xxvvv’是填充字符串,4是填充字符串的长度,若填充字符串长度超过4,则截取前4位填充,若不超过4,则全部填充)

实例二:SQL> select lpad('aaabbb',10,'x') from dual;

LPAD('AAABBB',10,'X')
---------------------
xxxxaaabbb
从左边开始对字符串'AAABBB'进行填充(‘aaabbb’:被填充字符串,10:填充后字符串长度,‘x’:填充字符串,填充后的字符串长度为10)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template