datetime类型与timestamp类型有什么区别?
解决方案 »
- insert 问题 请高手进来看看
- oralce提高自查询效率,我写的要0.094秒,这个效率不行 请高手指教
- 各位,有什么好的第三方工具,可以吧oracle里面表结构自动生成表结构文档,最好还能生成表之间的关系图。
- 高手请进?
- 数据库中,表与表建立关系,什么时候必须用foreign key,用了后有什么效果,谢谢大家!
- 如何对子项求和
- 为鼓励大家及时结帖,能做到及时结帖的同志们进来领分:)
- 复杂的存储过程问题
- 请教Oracle中数据生成树的方法
- 现在开发oracle form大家用什么版本的工具
- oracle包调用问题
- 如何查到数据库字符集,谢谢AMERICAN_AMERICA.AL32UTF8
--2010-4-30 15:51:14
select systimestamp from dual;
--1 30-4月 -10 03.51.14.718000 下午 +08:00
The TIMESTAMP datatype is an extension of the DATE datatype. It stores the year, month, and day of the DATE datatype, plus hour, minute, and second values. This datatype is useful for storing precise time values. SQL> select sysdate from dual;SYSDATE
---------
30-APR-10SQL> select systimestamp from dual;SYSTIMESTAMP
---------------------------------------------------------------------------
30-APR-10 04.26.10.577624 PM +08:00SQL>
oracle没有datetime类型
--提取当前系统时间的时间戳
select systimestamp from dual;两个时间戳做差:DECLARE
d1 timestamp:=systimestamp;
tm number;
BEGIN
for i in 1..10000 loop
select i into tm FROM dual;
end loop;
dbms_output.put_line('使用select into耗时:'||(systimestamp-d1));
d1 := systimestamp;
for i in 1..10000 loop
tm := i;
end loop;
dbms_output.put_line('使用赋值的方式耗时:'||(systimestamp-d1));
END;
时间戳变成SCN号码:
SELECT timestamp_to_scn(systimestamp) FROM dual;
通过SCN换成时间戳:
SELECT scn_to_timestamp(<SCN号码>) FROM dual;通过查询根据时间戳被删除掉的数据,在回滚段中查找,若数据太早的回滚段被冲掉就会报错,不过最近的一般都能找到(假如有张表叫:test):
select versions_xid xid,
versions_operation op,
versions_startscn startscn,
versions_endscn endscn,
rowid,
test.*
from test versions between TIMESTAMP
to_timestamp('2010-04-30 12:20:00','YYYY-MM-DD HH24:MI:SS') and maxvalue;查找到对应的时间戳后可以根据时间戳进行那个时间点的数据恢复:
ALTER TABLE test ENABLE ROW MOVEMENT;--设置可以进行ROWID迁移
FLASHBACK TABLE test
to TIMESTAMP to_timestamp('2010-04-30 12:20:00','YYYY-MM-DD HH24:MI:SS');
ALTER TABLE test DISABLE ROW MOVEMENT;