What to use in DB2 for CURRENT_TIMESTAMP?

懵懂的女人 提交于 2019-12-06 04:39:20

问题


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
); 

As you can see there is

LAST_UPDATE_TIME timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

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


回答1:


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
);


来源:https://stackoverflow.com/questions/10118614/what-to-use-in-db2-for-current-timestamp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!