mysql5.6.4以下不支持多个字段类型为timestamp
原因說明:
One TIMESTAMP column in a table can have the current timestamp as the default value for initializing the column, as the auto-update value, or both. It is not possible to have the current timestamp be the default value for one column and the auto-update value for another column.
?
但是創建時間和更新時間是每個表必須的,所以使用觸發器解決:
delimiter $$
create trigger update_wh_order_trigger
BEFORE update on wh_order for each row
begin
set new.update_time = CURRENT_TIMESTAMP;
end;
$$;
建表語句:
create table wh_order(
id int(11) not null AUTO_INCREMENT COMMENT '系統編號',
order_no VARCHAR(64) DEFAULT '' COMMENT '訂單編號',
order_name VARCHAR(200) DEFAULT '' COMMENT '訂單名稱',
order_price decimal(12,4) DEFAULT 0.0000 COMMENT '訂單價格',
description VARCHAR(500) DEFAULT '' COMMENT '訂單描述',
remark VARCHAR(500) DEFAULT '' COMMENT '備注',
user_code VARCHAR(64) DEFAULT '' COMMENT '用戶編號',
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '添加時間',
update_time datetime not NULL COMMENT '更新時間',
data_status VARCHAR(2) DEFAULT 'T' COMMENT '數據狀態 T 有效 F 無效',
PRIMARY KEY(id)
) ENGINE = INNODB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8 COMMENT '訂單表';
?
轉載于:https://www.cnblogs.com/hy87/p/8414187.html
總結
以上是生活随笔為你收集整理的mysql5.6.4以下不支持多个字段类型为timestamp的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数据结构与算法(3)-----队列和栈
- 下一篇: iOS11 与 iPhone X适配的那