Sybase内置数据类型Timestamp

1> select @@version
2> 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> go
Msg 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> go
Warning: A non-null value cannot be inserted into a TIMESTAMP column by the
user. The database timestamp value has been inserted into the TIMESTAMP field
instead.
(1 row affected)
1> select * from test
2> 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 test
2> 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 test
2> go
 id          date         time               
 ----------- ------------ ------------------ 
           1  Jul 24 2014 0x00000000000a8bdb 
           2  Jul 24 2014 0x00000000000a8bec 
           3  Jul 24 2014 0x00000000000a8bf5 

(3 rows affected)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值