MYSQL设计表时,需要 两个TIMESTAMP 字段的情况 有时候,数据库表有这样的需求,要一个记录创建时间,一个记录修改时间。 理想中的设计是这样的,更新时间的初始值和创建时间一样: CREATE TABLE `test_table` (`id` INT( 10 ) NOT NULL,`create_time` TIMEST
MYSQL设计表时,需要 两个TIMESTAMP 字段的情况CREATE TABLE `test_table` ( `id` INT( 10 ) NOT NULL, `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE = INNODB;
CREATE TABLE `test_table` ( `id` INT( 10 ) NOT NULL, `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE = INNODB;
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
CREATE TABLE `test_table` ( `id` INT( 10 ) NOT NULL, `create_time` TIMESTAMP NOT NULL DEFAULT 0, `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE = INNODB;
INSERT INTO test_table (id, create_time, update_time) VALUES (1, NULL, NULL);
INSERT INTO test_table (id, update_time) VALUES (1, NULL);
UPDATE test_table (id) VALUES (2);
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号