我在想这样的事情:
`post_modified` int(11) NOT NULL DEFAULT UNIX_TIMESTAMP (NOW ()) ON UPDATE UNIX_TIMESTAMP (NOW ()),
但是这段代码不起作用。
最佳答案
Note : I have no idea about the performance of MYSQL TRIGGER
Please go through these links
您可以为此创建触发器。
for insertion
在为每个行设置新的 {table_name} 插入之前创建触发器 {trigger_name}。{field_name} = UNIX_TIMESTAMP(NOW());
for update
在更新 {table_name} 之前创建触发器 {trigger_name} FOR EACH ROW SET new.{field_name} = UNIX_TIMESTAMP(NOW());
关于mysql - 如何将 mysql 列的默认值设置为 unix_timestamp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13124632/