Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 MySQL 表中有一个时间戳列。该列的默认值为CURRENT_TIMESTAMP,我想让该列的ON UPDATE属性也等于,CURRENT_TIMESTAMP而不必删除并重新添加该列,因为这会导致我丢失所有数据。
CURRENT_TIMESTAMP
这可能吗?
您应该能够通过以下ALTER语句成功地做到这一点:
ALTER
ALTER TABLE yourtable MODIFY the_timestamp_column TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
它在我的快速测试中正常工作。