一:

一条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;

posted on 2011-09-15 16:14  小魏的程序之家  阅读(227)  评论(0)    收藏  举报