单行字符串函数用于操作字符串数据,他们大多数有一个或多个参数,其中绝大多数返回字符串 ascii()
c1是一字符串,返回c1第一个字母的ascii码,他的逆函数是chr() select ascii(''a'') big_a,ascii(''z'') big_z from empbig_a big_z65 122
chr()[nchar_cs]
i是一个数字,函数返回十进制表示的字符 select chr(65),chr(122),chr(223) from empchr65 chr122 chr223a z b
concat(,)
c1,c2均为字符串,函数将c2连接到c1的后面,如果c1为null,将返回c2.如果c2为null,则返回c1,如果c1、c2都为null,则返回null。他和操作符||返回的结果相同 select concat(''slobo '',''svoboda'') username from dualusernameslobo syoboda
initcap()
c1为一字符串。函数将每个单词的第一个字母大写其它字母小写返回。单词由空格,控制字符,标点符号限制。 select initcap(''veni,vedi,vici'') ceasar from dualceasarveni,vedi,vici
instr(,[,[,]])
c1,c2均为字符串,i,j为整数。函数返回c2在c1中第j次出现的位置,搜索从c1的第i个字符开始。当没有发现需要的字符时返回0,如果i为负数,那么搜索将从右到左进行,但是位置的计算还是从左到右,i和j的缺省值为1. select instr(''mississippi'',''i'',3,3) from dualinstr(''mississippi'',''i'',3,3)11select instr(''mississippi'',''i'',-2,3) from dualinstr(''mississippi'',''i'',3,3)2
instrb(,[,i[,j])
与instr()函数一样,只是他返回的是字节,对于单字节instrb()等于instr() length()
c1为字符串,返回c1的长度,如果c1为null,那么将返回null值。 select length(''ipso facto'') ergo from dualergo10
lengthb()
与length()一样,返回字节。 lower()
返回c的小写字符,经常出现在where子串中
select lower(colorname) from itemdetail where lower(colorname) like ''%white%''colornamewinterwhite
lpad(,[,])
c1,c2均为字符串,i为整数。在c1的左侧用c2字符串补足致长度i,可多次重复,如果i小于c1的长度,那么只返回i那么长的c1字符,其他的将被截去。c2的缺省值为单空格,参见rpad。 select lpad(answer,7,'''') padded,answer unpadded from question;padded unpadded yes yesno nomaybe maybe