geew
V2EX  ›  问与答

[MySQL] 自动当前时间戳

  •  
  •   geew · Sep 5, 2013 · 3432 views
    This topic created in 4830 days ago, the information mentioned may be changed or developed.
    知道这样的
    created timestamp not null default current_timestamp;


    获取时间戳的函数:
    select unix_timestamp();

    有没有字段为int型自动插入时间戳的呢?
    -- created int(11) not null default (当前时间戳) ???
    2 replies  •  1970-01-01 08:00:00 +08:00
    zzNucker
    zzNucker
    Sep 5, 2013
    1
    应该没的吧 自动时间戳只能是timestamp类型
    qsun
    qsun
    Sep 5, 2013
    2
    可以做个trigger, on update/insert
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4289 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 263ms · UTC 07:24 · PVG 15:24 · LAX 23:24 · JFK 02:24
    ♥ Do have faith in what you're doing.