Liquibase:如何将日期列的默认值设置为“现在".是否采用UTC格式? [英] Liquibase: How to set the default value of a date column to be "now" in UTC format?

查看:578
本文介绍了Liquibase:如何将日期列的默认值设置为“现在".是否采用UTC格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将UTC格式的日期列的默认值设置为现在"?我认为答案涉及列元素上的defaultValueComputed属性.

How do you set the default value of a date column to be "now" in UTC format? I think the answer involves the defaultValueComputed attribute on the column element.

文档指出:

defaultValueComputed从函数或函数返回的值. 过程调用.此属性将包含要调用的函数.

defaultValueComputed A value that is returned from a function or procedure call. This attribute will contain the function to call.

该函数应该写成什么语言? Java的?该函数应该是我要使用的特定于数据库供应商的日期函数吗?我可以阅读有关此主题的更多文档吗?

What langauge is the function referred to supposed to be written in? Java? Is the function supposed to be the database vendor -specific date function I want to use? Is there any more documentation I can read on this topic?

推荐答案

也许此主题在liquibase论坛中会有所帮助吗?

Maybe this topic in the liquibase forum will help?

我认为defaultValueComputed将采用数据库特定的功能来表示现在".在mySQL中,它将为CURRENT_TIMESTAMP,因此它可能看起来像这样:

I think defaultValueComputed will take a database specific function to express "now". In mySQL it would be CURRENT_TIMESTAMP so it could look like this:

<createTable tableName="D_UserSession">
    <column name="ts" type="TIMESTAMP" defaultValueComputed="CURRENT_TIMESTAMP"/>
</createTable>

(从论坛帖子中复制.)

(Copied from the forum post.)

这篇关于Liquibase:如何将日期列的默认值设置为“现在".是否采用UTC格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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