mysql中表copy中的几种方法
1、方式1:
CREATE TABLE new_staff LIKE staff;

2、copy表,包括表结构和索引
但不会copy源表的数据

3、方式2:
create table new2_staff as (select * from staff);

4、copy表结构,包括数据,但索引,主键不会copy

5、有没有发现,create table 新表名 as 后面是 一个selelct 语句
因此
新表中可以只包括新表中部分字段
命令:
create table new2_staff as (select id,current_ from staff);

6、新表中只包括源表中的部分数据
命令:
create table new5_staff as (select * from staff where right(id,1)<5);
只复制5条数据

阅读量:150
阅读量:177
阅读量:115
阅读量:45
阅读量:104