
测试脚本如下:
1、创建测试表GetSysDate_Test:
create table GetSysDate_Test(t_id number,t_date date)
2、编写触发器trg_test:
create or replace trigger trg_test
before insert on GetSysDate_Test
for each row
when (new.t_date is null)
declare
begin
select sysdate into :new.t_date from dual
end trg_test
3、插入一条数据看效果:
insert into GetSysDate_Test(t_id)values(1)
commit
select * from GetSysDate_Test
你可以在读出时用Convert(Bigint,timestamp) as timestamp把时间戳转成Bigint类型.SQL2k的时间戳和别的数据库不同,不是日期型,是兼容Binary(8)(就象Bigint),
它是用数据库的全局变量@@DBTS来作时间戳的,实际上是一个行版本号.
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)