一:
一条mysql语句,复制表结构及主键
table1
id num
1 22
2 22
id为 int(11) primary auto_increment
复制数据及表结构,如下:
create newtable(id int(11) auto_increment primary key) select * from table1;
如果不想复制数据,如下:
create newtable(id int(11) auto_increment primary key) select * from table1 where 2=1;
二:
将查询出的数据插入到另一张表中
insert into newtable (uid) SELECT uid FROM oldtable;
浙公网安备 33010602011771号