Hi,
Is there any way to set the auto_increment value with the variable like
below.
mysql> set @id=10;
mysql> alter table suresh_copy auto_increment=@id;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near '@id' at line 1
It is working and below but need to work ab above.
mysql> alter table suresh_copy auto_increment=1000;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
From the MySQL documentation :
------------------------------
To change the value of the AUTO_INCREMENT counter to be used for new rows,
do this:
ALTER TABLE t2 AUTO_INCREMENT = value;
You cannot reset the counter to a value less than or equal to any that have
already been used.
Thanks
Suresh Kuna
| Thread |
|---|
| • setting auto_increment value with a local variable | Suresh Kuna | 19 Mar |