1. -----------数值函数
  2. ---绝对值
  3. select abs(-123) from dual;
  4.  
  5. --求模
  6. select mod (12,5) from dual;
  7.  
  8. --取整
  9. --上限值
  10. select ceil(123.45) from dual;
  11.  
  12. --下限值
  13. select floor (123.45) from dual;
  14.  
  15. --四舍五入
  16. select round(123.55) from dual;
  17.  
  18. select round(123.5267,2) from dual;--参数2表示小数点保留几位数
  19.  
  20. select round(126.5267,-1) from dual;--参数-1表示小数点向左移动1

  

字符串函数、替换函数----------------------------------------------------------------------------

  1. --截取,直接舍掉
  2. select trunc (123.52) from dual;
  3. select trunc (126.5267,2) from dual;
  4.  
  5. select cno, round ( avg(degree) ,2) from score group by cno;
  6.  
  7. --计算字符串长度
  8. select sname, length (sname) from student;
  9. select * from student where length (sname)>2;
  10.  
  11. --去空格
  12. select trim (' 付 s十b 亮 ') from dual;
  13. select ltrim (' 付 s十b 亮 ') from dual;
  14. select rtrim (' 付s十b亮 ') from dual;
  15.  
  16. --替换
  17. select replace(' abc def ', ' ' , '#' )from dual;--把空格换成#
  18.  
  19. select replace (sname, '王' '李') ,sname from student where sname like '王%';
  20.  
  21. --更新姓王的学生名称为姓李的
  22. update student set sname = replace (sname, '王' '李') where sname like '王%';
  23.  
  24. -- 查找字符串
  25. select instr ('bac', 'a') from dual; --数据库中索引和字符串位置从1开始
  26.  
  27. --截取字符串
  28. select substr('abdjhwkfjf', 2) from dual; --从第2位截取后面所有
  29. select substr('abdjhwkfjf', 2,5) from dual; --从第2个截取到第五位结束
  30. select substr('abdjhwkfjf', -8,5) from dual; --从右边向左数8位向右截取5位长度,长度不能是负数
  31.  
  32. select sname, substr(sname,1,1) || '同学'from student
  33.  
  34. --成绩为空的替换成0
  35. select t.*, nvl (degree ,0) from score t;
  36.  
  37. select t.*, nvl (degree ,100,0) from score t;-- 100是不为空的替换成100,为空的默认为0
  38.  
  39. --替换
  40. select t.* , decode (ssex, '1' , '男' ,'2','女' ,'不知道') from student t;
  41.  
  42. -- 返回当前用户
  43. select user from dual ;

  

聚合函数------------------------------------------------------

  1. --1.聚合函数 返回单个值
  2. --记录条数
  3. select count (sno)from student where sclass=95031;
  4.  
  5. --查平均成绩
  6. select sumdegree)/count (1) from score;
  7. select avg(degree) 平均值 from score;
  8.  
  9. --合计总成绩
  10. select sumdegree from score;
  11.  
  12. --最高成绩
  13. select * from score order by degree desc;
  14.  
  15. select max (degree)最大值, min (degree)最小值,avg(degree) 平均值 from score;

  

时间函数-------------------------------------------------------------------------

  1. --字符串数字之间运算
  2.  
  3. select cast('123' as number ) +123 from dual;
  4. ----------------------时间函数
  5. --查询系统时间
  6. select sysdate from dual;
  7.  
  8. insert into course values ('8-123','设计素描','856',sysdate);
  9.  
  10. select sysdate +1 from dual;
  11. --增加系统月份
  12. select add_months (sysdate,2) from dual;
  13. --查询系统本月最后一天
  14. select last_day (sysdate) from dual;

  

转换函数-----------------------------------------------------------------

  1. --22、查询和学号为108的同学同年出生的所有学生的SnoSnameSbirthday列。
  2.  
  3. select t.sbirthday, to_char (t.sbirthday,'yyyy-mm-dd hh24:mi:ss') from student t where sno='108'
  4.  
  5. select sno,sname,sbirthday from student where to_char (sbirthday,'yyyy')=
  6. (select to_char (t.sbirthday,'yyyy') from student t where sno='108');
  7.  
  8. select * from student where sbirthday >= to_date('1977-1-1','yyyy-mm-dd');

  

内置函数----整理、例题 、xmin的更多相关文章

  1. python3.7 内置函数整理

    #!/usr/bin/env python __author__ = "lrtao2010" #python3.7 内置函数整理 #abs(x) #返回数字的绝对值. 参数可以是整 ...

  2. python3.7内置函数整理笔记

    #python3.7 内置函数整理 #abs(x) #返回数字的绝对值. 参数可以是整数或浮点数. 如果参数是复数,则返回其大小 # print(abs(1)) # print(abs(-1)) # ...

  3. python常用内置函数整理

    1.最常见的内置函数是print print("Hello World!") 2.数学运算 abs(-5) # 取绝对值,也就是5 round(2.6) # 四舍五入取整,也就是3 ...

  4. golang中字符串内置函数整理

    字符串内置函数 1. 判断字符串的长度 str := "korea国" fmt.Println("str len=", len(str)) 2. 字符串遍历,同 ...

  5. pythonchallenge学到的python内置函数整理

    第0关: 计算x的n次方: x**n 第一关: maketrans(from,to):建立一个翻译规则,将from翻译成to的翻译规则,因为要从from翻译成to,所以俩个参数的长度必须一致 tran ...

  6. python内置函数整理

    1. abs() 函数返回数字的绝对值 2 divmod() 函数把除数和余数运算结果结合起来,返回一个包含商和余数的元组(a // b, a % b). 3, input() 相等于 eval(ra ...

  7. Python常用内置函数整理(lambda,reduce,zip,filter,map)

    匿名函数lambda lambda argument1,argument2,...argumentN :expression using arguments 1.lambda是一个表达式,而不是一个语 ...

  8. (二)SQL注入常用的内置函数整理(以MySql为例)

    [1]@@datadir 函数作用:返回数据库的存储目录构造SQL语句 select @@datadir;   [2]@@version_compile_os 函数作用:查看服务器的操作系统SQL语句 ...

  9. MySQL常用内置函数整理

    [1]@@datadir 函数作用:返回数据库的存储目录构造SQL语句 select @@datadir;ps:@@basedir返回mysql的根目录[2]@@version_compile_os ...

随机推荐

  1. 基于ZigBee的家居控制系统的设计与应用

    基于ZigBee的家居控制系统的设计与应用 PPT简介:http://pan.baidu.com/s/1i38PC6D 摘  要 智能家居是未来家居的发展方向,其利用先进的网络技术.计算机技术和无线通 ...

  2. java thread run and start

    在java中继承Thread,线程启动有两中方法:start()和run().下面简单介绍一下两者的区别. start():启动一个线程,此时线程处于就绪状态,然后调用Thread对象的run()方法 ...

  3. MOS X 下Apache服务器配置,及日志读取

    A01-配置Apache 在当前用户的目录创建一个文件夹 打开finder进入/etc/apache2/etc/apache2 是系统目录,默认不显示 进入该目录有两种方法 i. 显示所有隐藏和系统目 ...

  4. 程序员必懂:javaweb三大框架知识点总结

    原文链接:http://www.cnblogs.com/SXTkaifa/p/5968631.html javaweb三大框架知识点总结 一.Struts2的总结 1.Struts 2的工作流程,从请 ...

  5. 转载 linux内核 asmlinkage宏

    转载http://blog.chinaunix.net/uid-7390305-id-2057287.html 看一下/usr/include/asm/linkage.h里面的定义:#define a ...

  6. 第二篇:JMeter实现接口/性能自动化(JMeter/Ant/Jenkins)

    主要是对HTML报告的优化 如果按JMeter默认设置,生成报告如下:

  7. MySql数据库安装&修改密码&开启远程连接图解

    相关工具下载地址: mysql5.6 链接:http://pan.baidu.com/s/1o8ybn4I密码:aim1 SQLyog-12.0.8 链接:http://pan.baidu.com/s ...

  8. jQuery事件和JavaScript事件

    1.JavaScript事件: 属性 当以下情况发生时,出现此事件 FF N IE onabort 图像加载被中断 1 3 4 onblur 元素失去焦点 1 2 3 onchange 用户改变域的内 ...

  9. express-15 与生产相关的问题

    执行环境 Express支持执行环境的概念,它是一种在生产.开发或测试模式中运行应用程序的方法.实际上你可以按自己的想法创建很多种不同的环境. 要记住,开发.生产和测试是"标准"环 ...

  10. 标准W3C盒子模型和IE盒子模型

    标准W3C盒子模型和IE盒子模型   CSS盒子模型:网页设计中CSS技术所使用的一种思维模型. CSS盒子模型组成:外边距(margin).边框(border).内边距(padding).内容(co ...