易截截图软件、单文件、免安装、纯绿色、仅160KB

oracle 时间差


 //计算毫秒差(两个date类型的相减为天数差别,然后转换为毫秒)
select ceil(to_date('209-11-17 13:00:12','yyyy-mm-dd hh24:mi-ss')-to_date(2009-11-18 14:00:12','yyyy-mm-dd hh24:mi-ss') )from dual;
//计算相差月份
select (EXTRACT(year from to_date('209-11-17','yyyy-mm-dd'))-EXTRACT(year from to_date('2009-11-18','yyyy-mm-dd') ))*12+(EXTRACT(month from to_date('209-11-17','yyyy-mm-dd'))-EXTRACT(month from to_date('2009-11-18','yyyy-mm-dd') )) from dual;
//通过时间戳运算
select to_timestamp('2009-11-17 19:20:12 234','yyyy-mm-dd hh24:mi:ss ff')-to_timestamp('2009-11-16 11:12:34 167','yyyy-mm-dd hh24:mi:ss ff') from dual;
返回值为+000000010 00:02:24.00000000 字符串要转换为毫秒数字,自定义函数实现
//自定义用时间戳运算函数
create or replace function TIME_INTERVAL(endTime varchar2,startTime varchar2)
  return number
IS
p_1 varchar2(40);
begin
p_1 := to_timestamp(endTime,'yyyy-mm-dd hh24:mi:ss ff')-to_timestamp(startTime,'yyyy-mm-dd hh24:mi:ss ff');
return trunc(to_number(substr((p_1),1,instr(p_1,' '))))*24*60*60+to_number(substr((p_1),instr((p_1),' ')+1,2))*60*60+to_number(substr((p_1),instr((p_1),' ')+4,2))*60+to_number(substr((p_1),instr((p_1),' ')+7,2));
end;


相关文档:

oracle 表空间操作

oracle表空间操作详解
  1
  2
  3作者:   来源:    更新日期:2006-01-04 
  5
  6 
  7建立表空间
  8
  9CREATE TABLESPACE data01
 10DATAFILE '/ora ......

SQL语言基础考核(二)(oracle)

 2.根据Oracle 数据库scott 模式下的emp 表和dept 表,完成下列操作:
      (1) 查询20号部门的所有员工信息;
      (2) 查询所有工种为CLERK 的员工的员工号、员工名和部门号;
      (3) 查询奖金COMM 高于工资SAL 的员工信息;
  ......

oracle 恢复表到以前的某个状态

 select * from sys.smon_scn_time;
--scn 与时间的对应关系
每隔5分钟,系统产生一次系统时间标记与scn的匹配并存入sys.smon_scn_time表。
select * from student as of scn 592258
就可以看到在这个检查点的表的历史情况。
然后我们恢复到这个检查点
insert into student  select * from student a ......

Oracle的集合运算符

表1:temp1
AA    BB    CC
1      1      1
1      1      2
1      1      3
表2:temp2
AA    BB  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号