Even truncate does not reset ids to one
Posted: Thu Jan 12, 2006 6:56 am
1. You can understand the problem from the following output. Even after truncation, the id does not reset to 1 instead it starts with 6.
2. Is it possible to say a table to increment auto generated ids by two?
Code: Select all
mysql> insert into onlyid values(NULL);
Query OK, 1 row affected (0.06 sec)
mysql> insert into onlyid values(NULL);
Query OK, 1 row affected (0.06 sec)
mysql> insert into onlyid values(NULL);
Query OK, 1 row affected (0.01 sec)
mysql> insert into onlyid values(NULL);
Query OK, 1 row affected (0.03 sec)
mysql> insert into onlyid values(NULL);
Query OK, 1 row affected (0.03 sec)
mysql> select * from onlyid;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+----+
5 rows in set (0.00 sec)
mysql> truncate table onlyid;
Query OK, 5 rows affected (0.03 sec)
mysql> select * from onlyid;
Empty set (0.02 sec)
mysql> insert into onlyid values(NULL);
Query OK, 1 row affected (0.01 sec)
mysql> insert into onlyid values(NULL);
Query OK, 1 row affected (0.02 sec)
mysql> select * from onlyid;
+----+
| id |
+----+
| 6 |
| 7 |
+----+
2 rows in set (0.01 sec)