`
jinliyixi
  • 浏览: 17528 次
  • 性别: Icon_minigender_2
  • 来自: 南京
最近访客 更多访客>>
社区版块
存档分类
最新评论

oracle笔记一(常用各类函数)

阅读更多
三种使用Sqlplus 方式:
Sqlplus:
1. 进入cmd命令行窗口
2. sqlplus scott/wj
Sqlplusw:
开始->程序->Oracle->应用程序开发->sqlplus
Isqlplus:(浏览器)
http://localhost:5560/isqlplus



单行函数
1. lower(‘HELLO WORLD’);
2. upper(‘hello world’);
3. initcap(‘HELLO world’);首字母大写,其他小写
4. concat(‘hello’,‘world’);
5. substr(‘hello world’,1,5);
6. length(‘helloworld’);
7. instr(‘helloworld’,’w’);
8. lpad(salary,10,’*’);
9. rpad(salary,10,’*’);
10. trim(‘H’ from ‘Hello World’)(L,R);


数字函数
1. 四舍五入round(45.926,2); 45.93
2. 截断 trunc(45.926,2); 45.92
3. 取模mod(18,5) ; 3;


时间日期函数
1. 按指定的格式显示 to_char(sysdate+2/24,’yyyy-mm-dd hh24:mi:ss’);
2. 两个日期值之间间隔的月数months_between (sysdate,hiredate)
3. 加上月份add_months(sysdate,6);
4. 下一个周几 next_day(sysdate,’星期日’)/next_day(sysdate,1);
5. 本月的最后一天 last_day(sysdate);
6. 四舍五入 round(sysdate,’month’)

转换函数
1. to_char(‘$123456.78’,’$999G999D990);
2. to_number(‘$1234,56.78’,’$9999,99,99);
3. to_date(‘2009-11-13’,’yyyy-mm-dd’)


通用函数
1. 将空值转换成一个已知的值 NVL(ename,’name’);
2. NVL2(comm,sal+comm,sal)如果表达式1的值不为空,返回表达式2,否则返回表达式3;
3. 比较两个参数的值nullif(length(ename),length(job))如果相等,返回null;否则返回表达式1的值;
4. 返回参数列表中第一个非空值coalesce(sal+comm,sal,0)

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics