3.2 验证
下面我们可以来验证一下上面的分析结果:
set @@time_zone = '+8:00';
drop table if exists heyf;
create table heyf (id int ,curtime timestamp) type myisam;
insert into heyf values (11,'2009-03-09 14:22:48');
system hexdump /opt/mysql/data/test/heyf.MYD
------------------------------------
0000000 0bfd 0000 b800 b4b5 0049
0000009
------------------------------------
其中:
fd : 标志位
0b 00 00 00 : COL1 ,INT = 11
b8 b5 b4 49 : 即时间.由于是反向存储,所以需要反向读取: 49b4b5b8
在这里我们正好来进行反演测试:
1) b8 b5 b4 49 --> 49b4b5b8
2) select conv('49b4b5b8',16,10) ;
--> 1236579768
3) select FROM_UNIXTIME(1236579768) ;
--> '2009-03-09 14:22:48'
我们看到,这个时间前后刚好一致!