资源描述:
《PLSQL常用函数》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、PL/SQL函數2008-01-1810:56--【字符串函数】--字符串截取substr(字段名,起始点,个数)selectName,substr(Name,2,4),substr(Name,0,3),substr(Name,-2,3),substr(Name,-2,1)fromt1;--字符串从前面取三个(0开始)selectName,substr(Name,0,3)fromt1;--字符串从后面取三个selectName,substr(Name,-3,3),length(Name)串长度fromt1;SELECTASCII('A'),ASCI
2、I('B')fromdual;selectCHR(100),CHR(80)fromdual;selectCONCAT(CHR(65),CONCAT(CHR(67),CHR(98)))fromdual;selectCHR(65)
3、
4、CHR(66)
5、
6、CHR(76)fromdual;--将每个单词的第一个字母大写其它字母小写返回。selectINITCAP('substr,abc,substring')fromdual;--返回i在MISSISSIPPI中第3次出现的位置,selectINSTR('Mississippi','i',5,3)fromdu
7、al;selectINSTR('Mississippi','i',-2,3)fromdual;--返回的是字节selectINSTRB('Mississippi','i',5,3)fromdual;selectINSTRB('Mississippi','i',-2,3)fromdual;--长度selectlength('WHOAREYOU')fromdual;selectnvl(null,'空')fromdual;--小写selectlower('WHoareYou')fromdual;--LPAD左侧用字符串补足到一定长度selectLPAD(
8、'DFSDf................',9,'WHO')fromdual;selectLPAD('DFSD',9,'WHO')fromdual;selectLPAD('DFSD',9,'')fromdual;selectLPAD('DFSD',length('DFSD')+length('WHO......'),'WHO......')fromdual;--把最左边的字符去掉,使其第一个字符不在其中selectltrim('Mississippi','Mis')fromdual;selectltrim('Mississippi','miD'
9、)fromdual;--RPAD右侧用字符串补足到一定长度selectRPAD('DFSDf................',9,'WHO')fromdual;selectRPAD('DFSD',9,'WHO')fromdual;selectRPAD('DFSD',9,'')fromdual;selectRPAD('DFSD',length('DFSD')+length('WHO......'),'WHO......')fromdual;--把最右边的字符去掉,使其第一个字符不在其中selectRtrim('Mississippi','Mis')
10、fromdual;selectRtrim('Mississippi','miD')fromdual;--替换selectREPLACE('uptown','up','down')fromdual;--substr和substrbselectSUBSTR('Message',1,4)fromdual;selectSUBSTR('ABCDEFG',5)fromdual;selectsubstrb('国际劳动节国营农场',5)fromdual;selectsubstrb('国际劳动节国营农场',2)fromdual;selectsubstrb('国际劳动
11、节国营农场',4,8)fromdual;selectsubstrb('国际劳动节国营农场',3,8)fromdual;--发音selectSOUNDEX('dawes')Dawes,SOUNDEX('daws')Daws,SOUNDEX('dawson')fromdual;--translateselectTRANSLATE('ABCDefghijklmn','eg','替代')testfromdual;selectTRIM('Spacepadded 0..o0..')trimfromdual;selectUPPER('abDCCfasdfsda
12、fasdf')fromdual;--【数学函数】所有函数都有数字参数并返回数字值。所有三角函数的操作数和值都是弧度而不是角