您现在的位置是:主页 > news > 教育行业网站怎么做/免费模板网站
教育行业网站怎么做/免费模板网站
admin2025/5/24 15:19:30【news】
简介教育行业网站怎么做,免费模板网站,php网站开发实训报告,无尺码精品产品我们可以为时间戳指定一个默认值,以避免出现此问题。这篇文章提供了详细的解决方法:http : //gusiev.com/2009/04/update-and-create-timestamps-with-mysql/create table test_table(id integer not null auto_increment primary key,stamp_created tim…
我们可以为时间戳指定一个默认值,以避免出现此问题。
这篇文章提供了详细的解决方法:http : //gusiev.com/2009/04/update-and-create-timestamps-with-mysql/
create table test_table(
id integer not null auto_increment primary key,
stamp_created timestamp default '0000-00-00 00:00:00',
stamp_updated timestamp default now() on update now()
);
请注意,在“插入”期间必须在两列中输入空值:
mysql> insert into test_table(stamp_created, stamp_updated) values(null, null);
Query OK, 1 row affected (0.06 sec)
mysql> select * from t5;
+----+---------------------+---------------------+
| id | stamp_created | stamp_updated |
+----+---------------------+---------------------+
| 2 | 2009-04-30 09:44:35 | 2009-04-30 09:44:35 |
+----+---------------------+---------------------+
2 rows in set (0.00 sec)
mysql> update test_table set id = 3 where id = 2;
Query OK, 1 row affected (0.05 sec) Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from test_table;
+----+---------------------+---------------------+
| id | stamp_created | stamp_updated |
+----+---------------------+---------------------+
| 3 | 2009-04-30 09:44:35 | 2009-04-30 09:46:59 |
+----+---------------------+---------------------+
2 rows in set (0.00 sec)