没有缺点,使用时间戳(9)如果有意义.
时间戳(9)和时间戳(1)使用相同的空间量,其性能相同.我只能找到一个有性能差异的情况,在这种情况下,时间戳(9)实际上比时间戳(1)快.
(我将为您省下许多无聊的代码,插入到时间戳(1)和时间戳(9)列中,并对其进行比较
对他们的操作.)
这表明它们使用相同的空间量(插入许多值并比较dba_segments):
--Create tables with timestamps and populate them with the same data (with different precision)
--Set initial and next to a low value so we can closely check the segment size)
create table timestamp1 (t1 timestamp(1), t2 timestamp(1), t3 timestamp(1), t4 timestamp(1), t5 timestamp(1))
storage(initial 65536 next 65536);
insert into timestamp1
select current_timestamp(1), current_timestamp(1), current_timestamp(1), current_timestamp(1), current_timestamp(1)
from dual connect by level <= 100000;
create table timestamp9 (t1 timestamp(9), t2 timestamp(9), t3 timestamp(9), t4 timestamp(9), t5 timestamp(9))
storage(initial 65536 next 65536);
insert into timestamp9
select current_timestamp(9), current_timestamp(9), current_timestamp(9), current_timestamp(9), current_timestamp(9)
from dual connect by level <= 100000;
--Segment size is identical
select segment_name, bytes from dba_segments where segment_name in ('TIMESTAMP1', 'TIMESTAMP9');
--SEGMENT_NAME BYTES
--TIMESTAMP1 8388608
--TIMESTAMP9 8388608
这是时间戳(9)在使用current_timestamp时更快,您可能需要在某些时候使用它来生成数据.但是我们只谈到我的慢桌面上大约0.175和0.25秒之间的差异来产生100K的时间戳.我不知道为什么时间戳(9)更快,也许时间戳总是生成为时间戳(9),然后四舍五入到其他精度?
--current_timestamp(9) is slightly faster than current_timestamp(1)
select count(*) from
(
select *
from dual
--where current_timestamp(9) = current_timestamp(9)
where current_timestamp(1) = current_timestamp(1)
connect by level <= 100000
);
编辑:性能差异存在于10g而不是11g.