mysql timestamp查询时候自动更新问题 本帖最后由 shiningsb 于 2009-06-05 10:31:03 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 为啥查询出来都是2009-06-05 xx:xx:xx:你的记录是2号的? timestamp:字段中已经存入内容了? 我是先建表,插入记录,再SELECT ,内容没有变化,你是怎样的查询的 贴一下你的查询语句。应该不是MySQL的问题。 MySQL上的测试正常啊,没有你所说的那种情况。`createdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,create table t2 (`createdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP);insert into t2 values ('2009-06-02 13:33:30');insert into t2 values ('2009-06-02 14:33:30');insert into t2 values ('2009-06-02 17:33:30');insert into t2 values ('2009-06-03 13:33:30');insert into t2 values (null);mysql> create table t2 (`createdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP);Query OK, 0 rows affected (0.09 sec)mysql> insert into t2 values ('2009-06-02 13:33:30');Query OK, 1 row affected (0.33 sec)mysql> insert into t2 values ('2009-06-02 14:33:30');Query OK, 1 row affected (0.02 sec)mysql> insert into t2 values ('2009-06-02 17:33:30');Query OK, 1 row affected (0.03 sec)mysql> insert into t2 values ('2009-06-03 13:33:30');Query OK, 1 row affected (0.02 sec)mysql> insert into t2 values (null);Query OK, 1 row affected (0.02 sec)mysql> select * from t2;+---------------------+| createdate |+---------------------+| 2009-06-02 13:33:30 || 2009-06-02 14:33:30 || 2009-06-02 17:33:30 || 2009-06-03 13:33:30 || 2009-06-05 11:47:02 |+---------------------+5 rows in set (0.00 sec)mysql> select version();+----------------------+| version() |+----------------------+| 5.1.33-community-log |+----------------------+1 row in set (0.06 sec)mysql> 遇到的一种情况是timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP每次更新数据库记录,时间都会变到最新的 mysql命令行中直接执行,返回什么呢?select createdate from tbl_name; 大家应该是误解LZ的意思了,LZ的意思是每次SQL查询 那么SQL的数据表自动更新查询时间,应该是这个意思。关注中,估计不能,需要通过程序来完成。 求助longblob问题 mysql 流水号并发问题如何解决 [求助] 数据内容为空时 ,大家一般存为NULL还是空字串? mysql中查询语句问题 截取中英文混合字符串(前3个字符) select into null 付值问题 有没有类似oracle中rownum的关键字? 联网后每分钟插入一条数据,判断联网时间 MySqlCommand. Parameters.AddWithValue() 插入数据为null 这种需求,表怎么设计 请哪位高手发一份软件需求说明书的模板给我,谢谢了~ 联合查询速度快还是循环多次单表查询速度快?
insert into t2 values ('2009-06-02 13:33:30');
insert into t2 values ('2009-06-02 14:33:30');
insert into t2 values ('2009-06-02 17:33:30');
insert into t2 values ('2009-06-03 13:33:30');
insert into t2 values (null);mysql> create table t2 (`createdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP);
Query OK, 0 rows affected (0.09 sec)mysql> insert into t2 values ('2009-06-02 13:33:30');
Query OK, 1 row affected (0.33 sec)mysql> insert into t2 values ('2009-06-02 14:33:30');
Query OK, 1 row affected (0.02 sec)mysql> insert into t2 values ('2009-06-02 17:33:30');
Query OK, 1 row affected (0.03 sec)mysql> insert into t2 values ('2009-06-03 13:33:30');
Query OK, 1 row affected (0.02 sec)mysql> insert into t2 values (null);
Query OK, 1 row affected (0.02 sec)mysql> select * from t2;
+---------------------+
| createdate |
+---------------------+
| 2009-06-02 13:33:30 |
| 2009-06-02 14:33:30 |
| 2009-06-02 17:33:30 |
| 2009-06-03 13:33:30 |
| 2009-06-05 11:47:02 |
+---------------------+
5 rows in set (0.00 sec)mysql> select version();
+----------------------+
| version() |
+----------------------+
| 5.1.33-community-log |
+----------------------+
1 row in set (0.06 sec)mysql>
select createdate from tbl_name;