第五章++++常用函数.pptVIP

  • 0
  • 0
  • 约6.79千字
  • 约 20页
  • 2019-09-05 发布于湖北
  • 举报
第五章 常用函数 计算机科学与工程学院 2013年3月 Oracle内置函数(1) Dual 表:是一个虚拟表,用于查询那些不属于实际表里的内容。 例: select 3+3 from dual ; 例:查看当前用户 select user from dual; 例:查看当前日期、时间 select sysdate from dual; Oracle内置函数(2) 字符函数 1 LOWER(char) 返回字符串,并将所有的字符小写。 例:select lower(AaBbCcDd)AaBbCcDd from dual; 例:将emp表的员工姓名全部转换为小写 select lower(eNAME) FROM scott.EMP; 例:查询员工姓名和工资,将emp表的员工姓名全部小写显示 select lower(ENAME) , sal from scott.emp; 2 UPPER( char) 返回字符串,并将所有的字符大写。 例: select upper(AaBbCcDd) from dual; 例:将员工名字按大写方式显示 select UPPER(ENAME) FROM scott.EMP; Oracle内置函数(3) 字符函数 3 LENGTH : 返回字符串的长度; 例:显示正好有5个字符的员工姓名 select * from scott.emp where length(ename) =5; 注意:ename字段为varchar(10)类型,length(ename) 是实际长度而不是定义时的长度,所以可以查询到实际长度为5的名字。 例:显示正好有10个字符的员工姓名 select * from scott.emp where length(ename) =10; 4 SUBSTR(string,start,count) :取子字符串,从start开始,取count个 例: select substr3,8) from dual; 例:显示所有员工姓名的前3个字母 select substr(ename ,1,3) from scott.emp; Oracle内置函数(4) 字符函数 4 SUBSTR(string,start,count) (续) 例:以首字母大写方式显示员工的姓名 ① 完成首字母大写 select upper(substr(ename,1,1)) from scott.emp ; ②完成后面字母小写 select lower(substr(ename,2,length(ename)-1)) from scott.emp ; ③ 合并 select upper(substr(ename,1,1)) || lower(substr(ename,2,length(ename)-1)) from scott.emp ; Oracle内置函数(5) 字符函数 4 SUBSTR(string,start,count) (续) 例:以首字母小写方式显示员工的姓名 ① 完成首字

文档评论(0)

1亿VIP精品文档

相关文档