Sybase内置数据类型Timestamp

来源:互联网 发布:淘宝免费购物 编辑:程序博客网 时间:2024/06/07 12:26
1> select @@version2> go                                                                                                                                                                                                                                                                  -------------------------------------------------------------------------------- Adaptive Server Enterprise/15.5/EBF 18164 SMP ESD#2/P/x86_64/Enterprise Linux/a         sear155/2514/64-bit/FBO/Wed Aug 25 11:17:26 2010                                                                                                                                 (1 row affected)

一张表中只能创建一个Timestamp类型字段:

1> create table test(t1 timestamp, t2 timestamp)2> goMsg 2738, Level 16, State 2:Server 'SYBASE', Line 1:A table can only have one timestamp column.  Since table 'test' already has one,you can't add the column 't2'.1> create table test(id int, date date, time timestamp)2> go

Sybase中的Timestamp不是一种时间类型(这点和Oracle、MySQL不一样):

1> insert into test values(1, getdate(), getdate())2> goWarning: A non-null value cannot be inserted into a TIMESTAMP column by theuser. The database timestamp value has been inserted into the TIMESTAMP fieldinstead.(1 row affected)1> select * from test2> go id          date         time                ----------- ------------ ------------------            1  Jul 24 2014 0x00000000000a8b75 (1 row affected)

Timestamp类型字段是一个顺序号(只增不减),本质上算是一种“戳”,用来记录跟踪数据库中数据页的修改情况(主要被系统使用进行自身维护工作,用户不可以直接修改、处理这种数据类型的数据):

1> update test set date = getdate()2> go(1 row affected)1> select * from test2> go id          date         time                ----------- ------------ ------------------            1  Jul 24 2014 0x00000000000a8bdb (1 row affected)

插入的时候不指定具体值,或者插入null,数据库都会在不报错的情况下完成该字段的填充:

1> insert into test values(2, getdate(), null)2> go(1 row affected)1> insert into test(id, date) values(3, getdate())2> go(1 row affected)1> select * from test2> go id          date         time                ----------- ------------ ------------------            1  Jul 24 2014 0x00000000000a8bdb            2  Jul 24 2014 0x00000000000a8bec            3  Jul 24 2014 0x00000000000a8bf5 (3 rows affected)

 

0 0
原创粉丝点击