在DB2中为CURRENT_TIMESTAMP使用什么? [英] What to use in DB2 for CURRENT_TIMESTAMP?

查看:1069
本文介绍了在DB2中为CURRENT_TIMESTAMP使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一些MySQL语句转换为DB2数据库,但在以下查询中遇到了问题

I am converting some of my MySQL statements to DB2 database, but I faced a problem on the following query

CREATE TABLE RFX_EVENT_MAPPING (
  EVENT_TYPE varchar(4) NOT NULL,
  EVENT_DESC varchar(50) NOT NULL,
  EVENT_CLASS varchar(50) default NULL,
  OWNER varchar(6) default NULL,
  LAST_UPDATE_TIME timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  LAST_UPDATE_USER varchar(20) NOT NULL
); 

您可以看到有

LAST_UPDATE_TIME timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

哪个不是可以正常工作,以便如何使用db2实现相同的功能?

Which is not working so how can I achieve the same functionality with db2?

推荐答案

在用于Linux,UNIX,Windows的DB2 9.7中,IBM添加了行更改时间戳记的概念。

In DB2 9.7 for Linux, UNIX, Windows, IBM added the concept of a row change timestamp.

create table rcttest (
   c1 int,
   c2 char(10),
   insert_ts timestamp not null with default current timestamp,
   change_ts timestamp not null generated always for each row 
                                on update as row change timestamp
);

这篇关于在DB2中为CURRENT_TIMESTAMP使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆