1、须事先创建一个表
CREATE TABLE TEST(
ID INT NOT NULL,
NAME VATCHAR(20),
UNIQUE A (ID)
);
2、MySQL复制表语法
create table newtablename like test;
意思:创建一个新表模仿test表;
create table test3 as(
select username,password from tablename
)
意思:创建表3的字段从tablename里面拿出来
3、向表里复制数据
insert into newtablename select * from newtablename;
也可以加条件
insert into newtablename select * from newtablename where ?
创建表的时候同时录入数据
create table test4 as (
select * from newtablename
);
意思:创建表4的时候从newtablename表里拿字段同时拿数据,select * 这是支持选字段的,创建表查询的时候也是加过滤条件;