nesto ti tu lose radis:
Code:
mysql> create table t1 (a int auto_increment primary key not null, b int, c timestamp not null default current_timestamp) engine=myisam;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t1 (b) values (1),(2),(3),(4),(22),(23),(26);
Query OK, 7 rows affected (0.00 sec)
Records: 7 Duplicates: 0 Warnings: 0
mysql> select * from t1;
+---+------+---------------------+
| a | b | c |
+---+------+---------------------+
| 1 | 1 | 2012-06-29 15:29:42 |
| 2 | 2 | 2012-06-29 15:29:42 |
| 3 | 3 | 2012-06-29 15:29:42 |
| 4 | 4 | 2012-06-29 15:29:42 |
| 5 | 22 | 2012-06-29 15:29:42 |
| 6 | 23 | 2012-06-29 15:29:42 |
| 7 | 26 | 2012-06-29 15:29:42 |
+---+------+---------------------+
7 rows in set (0.00 sec)
mysql> insert into t1 (b) values (1),(2),(3),(4),(22),(23),(26);
Query OK, 7 rows affected (0.00 sec)
Records: 7 Duplicates: 0 Warnings: 0
mysql> select * from t1;
+----+------+---------------------+
| a | b | c |
+----+------+---------------------+
| 1 | 1 | 2012-06-29 15:29:42 |
| 2 | 2 | 2012-06-29 15:29:42 |
| 3 | 3 | 2012-06-29 15:29:42 |
| 4 | 4 | 2012-06-29 15:29:42 |
| 5 | 22 | 2012-06-29 15:29:42 |
| 6 | 23 | 2012-06-29 15:29:42 |
| 7 | 26 | 2012-06-29 15:29:42 |
| 8 | 1 | 2012-06-29 15:30:05 |
| 9 | 2 | 2012-06-29 15:30:05 |
| 10 | 3 | 2012-06-29 15:30:05 |
| 11 | 4 | 2012-06-29 15:30:05 |
| 12 | 22 | 2012-06-29 15:30:05 |
| 13 | 23 | 2012-06-29 15:30:05 |
| 14 | 26 | 2012-06-29 15:30:05 |
+----+------+---------------------+
14 rows in set (0.00 sec)
mysql> update t1 set b=999 where a=7;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from t1;
+----+------+---------------------+
| a | b | c |
+----+------+---------------------+
| 1 | 1 | 2012-06-29 15:29:42 |
| 2 | 2 | 2012-06-29 15:29:42 |
| 3 | 3 | 2012-06-29 15:29:42 |
| 4 | 4 | 2012-06-29 15:29:42 |
| 5 | 22 | 2012-06-29 15:29:42 |
| 6 | 23 | 2012-06-29 15:29:42 |
| 7 | 999 | 2012-06-29 15:29:42 |
| 8 | 1 | 2012-06-29 15:30:05 |
| 9 | 2 | 2012-06-29 15:30:05 |
| 10 | 3 | 2012-06-29 15:30:05 |
| 11 | 4 | 2012-06-29 15:30:05 |
| 12 | 22 | 2012-06-29 15:30:05 |
| 13 | 23 | 2012-06-29 15:30:05 |
| 14 | 26 | 2012-06-29 15:30:05 |
+----+------+---------------------+
14 rows in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2012-06-29 15:30:37 |
+---------------------+
1 row in set (0.00 sec)
mysql> update t1 set b=999 where a=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from t1;
+----+------+---------------------+
| a | b | c |
+----+------+---------------------+
| 1 | 1 | 2012-06-29 15:29:42 |
| 2 | 999 | 2012-06-29 15:29:42 |
| 3 | 3 | 2012-06-29 15:29:42 |
| 4 | 4 | 2012-06-29 15:29:42 |
| 5 | 22 | 2012-06-29 15:29:42 |
| 6 | 23 | 2012-06-29 15:29:42 |
| 7 | 999 | 2012-06-29 15:29:42 |
| 8 | 1 | 2012-06-29 15:30:05 |
| 9 | 2 | 2012-06-29 15:30:05 |
| 10 | 3 | 2012-06-29 15:30:05 |
| 11 | 4 | 2012-06-29 15:30:05 |
| 12 | 22 | 2012-06-29 15:30:05 |
| 13 | 23 | 2012-06-29 15:30:05 |
| 14 | 26 | 2012-06-29 15:30:05 |
+----+------+---------------------+
14 rows in set (0.00 sec)
mysql> update t1 set b=999,c=null where a=10;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from t1;
+----+------+---------------------+
| a | b | c |
+----+------+---------------------+
| 1 | 1 | 2012-06-29 15:29:42 |
| 2 | 999 | 2012-06-29 15:29:42 |
| 3 | 3 | 2012-06-29 15:29:42 |
| 4 | 4 | 2012-06-29 15:29:42 |
| 5 | 22 | 2012-06-29 15:29:42 |
| 6 | 23 | 2012-06-29 15:29:42 |
| 7 | 999 | 2012-06-29 15:29:42 |
| 8 | 1 | 2012-06-29 15:30:05 |
| 9 | 2 | 2012-06-29 15:30:05 |
| 10 | 999 | 2012-06-29 15:32:00 |
| 11 | 4 | 2012-06-29 15:30:05 |
| 12 | 22 | 2012-06-29 15:30:05 |
| 13 | 23 | 2012-06-29 15:30:05 |
| 14 | 26 | 2012-06-29 15:30:05 |
+----+------+---------------------+
14 rows in set (0.00 sec)
mysql> update t1 set b=555 where a=1 limit 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from t1;
+----+------+---------------------+
| a | b | c |
+----+------+---------------------+
| 1 | 555 | 2012-06-29 15:29:42 |
| 2 | 999 | 2012-06-29 15:29:42 |
| 3 | 3 | 2012-06-29 15:29:42 |
| 4 | 4 | 2012-06-29 15:29:42 |
| 5 | 22 | 2012-06-29 15:29:42 |
| 6 | 23 | 2012-06-29 15:29:42 |
| 7 | 999 | 2012-06-29 15:29:42 |
| 8 | 1 | 2012-06-29 15:30:05 |
| 9 | 2 | 2012-06-29 15:30:05 |
| 10 | 999 | 2012-06-29 15:32:00 |
| 11 | 4 | 2012-06-29 15:30:05 |
| 12 | 22 | 2012-06-29 15:30:05 |
| 13 | 23 | 2012-06-29 15:30:05 |
| 14 | 26 | 2012-06-29 15:30:05 |
+----+------+---------------------+
14 rows in set (0.00 sec)
mysql>
dakle kao sto vidis nijedan update (osim pretposlednjeg gde je to namerno) nije promenio vrednost za c, cak i sa limit 1 ...
cak i ako SVIMA promenim vrednost:
Code:
mysql> update t1 set b=1234;
Query OK, 14 rows affected (0.00 sec)
Rows matched: 14 Changed: 14 Warnings: 0
mysql> select * from t1;
+----+------+---------------------+
| a | b | c |
+----+------+---------------------+
| 1 | 1234 | 2012-06-29 15:29:42 |
| 2 | 1234 | 2012-06-29 15:29:42 |
| 3 | 1234 | 2012-06-29 15:29:42 |
| 4 | 1234 | 2012-06-29 15:29:42 |
| 5 | 1234 | 2012-06-29 15:29:42 |
| 6 | 1234 | 2012-06-29 15:29:42 |
| 7 | 1234 | 2012-06-29 15:29:42 |
| 8 | 1234 | 2012-06-29 15:30:05 |
| 9 | 1234 | 2012-06-29 15:30:05 |
| 10 | 1234 | 2012-06-29 15:32:00 |
| 11 | 1234 | 2012-06-29 15:30:05 |
| 12 | 1234 | 2012-06-29 15:30:05 |
| 13 | 1234 | 2012-06-29 15:30:05 |
| 14 | 1234 | 2012-06-29 15:30:05 |
+----+------+---------------------+
14 rows in set (0.00 sec)
mysql> update t1 set b=564 limit 2;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> select * from t1;
+----+------+---------------------+
| a | b | c |
+----+------+---------------------+
| 1 | 564 | 2012-06-29 15:29:42 |
| 2 | 564 | 2012-06-29 15:29:42 |
| 3 | 1234 | 2012-06-29 15:29:42 |
| 4 | 1234 | 2012-06-29 15:29:42 |
| 5 | 1234 | 2012-06-29 15:29:42 |
| 6 | 1234 | 2012-06-29 15:29:42 |
| 7 | 1234 | 2012-06-29 15:29:42 |
| 8 | 1234 | 2012-06-29 15:30:05 |
| 9 | 1234 | 2012-06-29 15:30:05 |
| 10 | 1234 | 2012-06-29 15:32:00 |
| 11 | 1234 | 2012-06-29 15:30:05 |
| 12 | 1234 | 2012-06-29 15:30:05 |
| 13 | 1234 | 2012-06-29 15:30:05 |
| 14 | 1234 | 2012-06-29 15:30:05 |
+----+------+---------------------+
14 rows in set (0.00 sec)
mysql>
datum se nece menjati ...
i da ne bude da je to zato sto ja ovde koristi myisam a ti mozda innodb:
Code:
mysql> alter table t1 engine=innodb;
Query OK, 14 rows affected (0.11 sec)
Records: 14 Duplicates: 0 Warnings: 0
mysql> update t1 set b=222 limit 2;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> select * from t1;
+----+------+---------------------+
| a | b | c |
+----+------+---------------------+
| 1 | 222 | 2012-06-29 15:29:42 |
| 2 | 222 | 2012-06-29 15:29:42 |
| 3 | 1234 | 2012-06-29 15:29:42 |
| 4 | 1234 | 2012-06-29 15:29:42 |
| 5 | 1234 | 2012-06-29 15:29:42 |
| 6 | 1234 | 2012-06-29 15:29:42 |
| 7 | 1234 | 2012-06-29 15:29:42 |
| 8 | 1234 | 2012-06-29 15:30:05 |
| 9 | 1234 | 2012-06-29 15:30:05 |
| 10 | 1234 | 2012-06-29 15:32:00 |
| 11 | 1234 | 2012-06-29 15:30:05 |
| 12 | 1234 | 2012-06-29 15:30:05 |
| 13 | 1234 | 2012-06-29 15:30:05 |
| 14 | 1234 | 2012-06-29 15:30:05 |
+----+------+---------------------+
14 rows in set (0.00 sec)
da li si siguran da nemas ti tu neke trigere koji ti brkaju loncice?