Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

CREATE TABLE new_table_name LIKE old_table_name com valores AUTO_INCREMENT de 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;

Thx ao meu irmão!