您的位置:首页 > 博客中心 > 数据库 >

oracle字符函数lower() upper() length() substr()

时间:2022-03-14 02:16

一,字符函数:  小写函数:lower();  用法:比如将一个表的所有名称都小写:  select lower(t.ename) from scott.emp t    大写函数:upper();  用法:比如将一个表的所有名称都大写:  select upper(t.ename) from scott.emp t    长度函数:length();  用法:比如将一个表的所有名称中为5个字符长度的取出:  select t.ename from scott.emp t where length(t.ename)= 5  注:长度是指字符串的长度 如“中国”为2 “ab”也为2    截取字符串:substr(char,m,n)  用法:比如显示所有员工的前三位字符  select substr(t.ename, 1 ,3 ) from scott.emp t    综合运用 :  以首字母大写方式显示所有员工姓名  1.select upper(substr(t.ename, 1 ,1 ))|| lower(substr(t.ename, 2 ,length(t.ename)-1)) from scott.emp t  2.  select  initcap(ename) from scott.emp; 

热门排行

今日推荐

热门手游