Mysql
 sql >> Database >  >> RDS >> Mysql

CREATE TABLE new_table_name COME old_table_name con i valori AUTO_INCREMENT di old_table_name

mysql> create table new_table like old_table;

mysql> select @my_auto_increment:=auto_increment from information_schema.tables where table_name='old_table';

mysql> set @query = CONCAT("alter table new_table auto_increment = ", @my_auto_increment);

mysql> prepare stmt from @query;

mysql> execute stmt;

mysql> deallocate prepare stmt;

Grazie a mio fratello!