六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 119|回复: 0

Oracal的Lpad函数

[复制链接]

升级  88%

10

主题

10

主题

10

主题

童生

Rank: 1

积分
44
 楼主| 发表于 2013-2-7 20:24:10 | 显示全部楼层 |阅读模式
翻译自:http://www.blogjava.net/amigoxie/archive/2007/04/26/113722.html
Oracal的Lpad函数
    翻译自:http://mfm088.itpub.net/post/22599/250400
    在Oracle/PLSQL中,lpad函数将左边的字符串填充一些特定的字符,其语法格式如下:   

     lpad( string1, padded_length, [ pad_string ] )
     其中string1是需要粘贴字符的字符串
     padded_length是返回的字符串的数量,如果这个数量比原字符串的长度要短,lpad函数将会把字符串截取成padded_length;

     pad_string是个可选参数,这个字符串是要粘贴到string1的左边,如果这个参数未写,lpad函数将会在string1的左边粘贴空格。
    例如:
         
lpad('tech', 7); 将返回' tech'

lpad('tech', 2); 将返回'te'
lpad('tech', 8, '0'); 将返回'0000tech'
lpad('tech on the net', 15, 'z'); 将返回 'tech on the net'
lpad('tech on the net', 16, 'z'); 将返回 'ztech on the net'
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表