oracle rpad()函数

来源:互联网 发布:红中麻将源码教程 编辑:程序博客网 时间:2024/04/29 04:58
oracle rpad()函数

rpad函数从右边对字符串使用指定的字符进行填充   
rpad(string,padded_length,[pad_string])   
string 表示:被填充的字符串   
padded_length表示:字符的长度,是返回的字符串的数量,如果这个数量比原字符串的长度要短,rpad函数将会把字符串截取成从左到右的n个字符;  
pad_string是个可选参数,这个字符串是要粘贴到string的右边,如果这个参数未写,lpad函数将会在string的右边粘贴空格。  
例如:   
rpad('tech', 7); 将返回'tech '   
rpad('tech', 2); 将返回'te'   
rpad('tech', 8, '0'); 将返回'tech0000'   
rpad('tech on the net', 15, 'z'); 将返回 'tech on the net'   
rpad('tech on the net', 16, 'z'); 将返回 'tech on the netz'

SQL> select rpad('aa',5)||decode('bbb',null,'',rpad('bbb',8))||rpad('cccc',12) from dual;
 
RPAD('AA',5)||DECODE('BBB',NUL
------------------------------
aa  bbb    cccc

转自:http://www.cnblogs.com/BetterWF/archive/2012/07/18/2597472.html

0 0
原创粉丝点击