you cannot have the indexes,pks and attributes like auto_increment, NOT NULL wont be copied into the new table if u just use
create table tablename select * from tablename2
you will have to do it in two steps
first create the table structure and then insert the data ...
CREATE TABLE table1 LIKE table2;
INSERT INTOtable1 SELECT * FROM 2;
Main Topics
Browse All Topics





by: Raynard7Posted on 2006-07-06 at 20:31:40ID: 17055983
I have just tried this with some simple tables;
create table `test`.`TableName1` ( `a` int (10) NULL , `b` int (19) NULL , `c` int (19) NULL );
insert into `test`.`tablename1` ( `a`, `b`, `c` ) values ( '1', '2', '3' );
insert into `test`.`tablename1` ( `a`, `b`, `c` ) values ( '4', '3', '2' );
create table tablename2 like tablename1 ;
insert into tablename2 (select * from tablename1) ;
and it worked perfectly; you may need to check your syntax and try again - because this is how it should work