字符串处理函数

博客介绍了数据库中多个字符串函数,如SUBSTR用于提取字符串部分内容,UPPER将字符串字母转为大写,LOWER转为小写,INITCAP使每个单词首字母大写,REPLACE替换字符串,LENGTH返回字符串长度,INSTR查找子字符串位置等,并给出了各函数的语法。

 

SELECT
SUBSTR('ABCDEFG',3,4),
SUBSTR('ABCDEFG',3),
SUBSTR('ABCDEFG',-3,3),
UPPER('jinhong'),
lower('X-DEF'),
REPLACE('JACK and JUE','J','BL'),
REPLACE('JACK AND LIFE', 'jack'),
REPLACE('JACK AND LIFE', 'JACK'),
LENGTH('BLAKE'),
INSTR('www.life.com.www', 'www.'),
INSTR('www.life.com.www', 'www',2),
'ONE'||'TWO'

FROM dual;
SUBSTR('ABCDEFG',3,4) SUBSTR('ABCDEFG',3) SUBSTR('ABCDEFG',-3,3) UPPER('JINHONG') LOWER('X-DEF') REPLACE('JACKANDJUE','J','BL') REPLACE('JACKANDLIFE','JACK') REPLACE('JACKANDLIFE','JACK') LENGTH('BLAKE') INSTR('WWW.LIFE.COM.WWW','WWW.') INSTR('WWW.LIFE.COM.WWW','WWW',2) 'ONE'||'TWO'
--------------------- ------------------- ---------------------- ---------------- -------------- ------------------------------ ----------------------------- ----------------------------- --------------- -------------------------------- --------------------------------- ------------
CDEF                  CDEFG               EFG                    JINHONG          x-def          BLACK and BLUE                 JACK AND LIFE                  AND LIFE                                   5                                1                                14 ONETWO       

 


SUBSTR:
Extracts a portion of a string.
Syntax:
SUBSTR(original_string,position[,substring_length])
It returns a portion of original_string, beginning at
If position is negative Oracle counts backward from the end of
The substring_length parameter is optional. If it is omitted, the function returns
UPPER:
Returns the string with all letters uppercase.
Syntax:
UPPER(original_string)
LOWER:
Returns the string with all letters lowercase.
Syntax:
LOWER(original_string)
INITCAP:
Returns the string with the first letter of each word in uppercase, all other letters in lowercase.
Syntax:
INITCAP(original_string)
REPLACE:
Returns the string with every occurrence of search_string
then all occurrences of search_string are removed
Syntax:
REPLACE(original_string,search_string,replacement_string)
LENGTH:
Returns the length of the string.
Syntax:
LENGTH(string)
INSTR:
Returns the position in which one string is found within another string.
Syntax:
INSTR(main_string,substring[,position[,occurrence]]
 

 

转载于:https://www.cnblogs.com/kakaisgood/p/9566147.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值