copy AUTO_INCREMENT value
Posted by: pierre boutet
Date: May 27, 2011 07:52AM

Hello !

I would like to do an sql request to copy the next auto_increment value of one table to another table.

I try :

SET @INCR =(SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'table_a' LIMIT 1);
ALTER TABLE `table_b` AUTO_INCREMENT = @INCR;

but it seems not accept variable in ATLER request;

I try :
UPDATE INFORMATION_SCHEMA.TABLES SET AUTO_INCREMENT = (SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'table_a' LIMIT 1) WHERE table_name = 'table_b';

but even root has not permissions to do it.

Is it possible to do such stuff ?

Thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
copy AUTO_INCREMENT value
7320
May 27, 2011 07:52AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.