复制MYSQL表结构的方法:
1、create table <newtable> select * from <oldtable>;
这种方法实际上是将oldtable中所有的内容连同表结构一起都拷贝过来到newtable中,当然我们可以用delete from newtable来删除数据。
不过这种方法的一个最不好的地方就是newtable中没有了oldtable的pri key、Extra(auto_increment)等属性。需要自己用"alter"添
加,而且容易搞错。
2、show create table <oldtable>;
将oldtable的创建命令列出。将该命令拷贝出来,更改table的名字,则可建立一个完全一样的表。
3、mysqldump
用mysqldump将表dump出来,改名字后再导回去或者直接在命令行中运行。
4、create table <newtable> select * from <oldtable> where 1<>1;
实现上是在复制表时过滤所有数据。
5、create table <newtable> like <oldtable>
与旧表完全一样,包括索引