mysql复制表命令

 

-- 复制全表字段
CREATE TABLE targetTable LIKE sourceTable;

INSERT INTO targetTable SELECT * FROM sourceTable;
CREATE TABLE 新表 select * from 旧表 where 1=2

 

-- 复制可选字段及数据
CREATE TABLE newadmin AS
(
    SELECT username, password FROM admin
)

-- 可以修改字段名及复制数据
CREATE TABLE newadmin AS
(  
    SELECT id, username AS uname, password AS pass FROM admin
)

-- 也可以复制一部分数据
CREATE TABLE newadmin AS
(
    SELECT * FROM admin WHERE LEFT(username,1) = s
)

 

mysql复制表命令

上一篇:菜鸟学数据库(六)——方便快捷的开启、关闭Oracle服务


下一篇:sql server 2008 数据库压缩log文件大小脚本(压缩本地文件,由百G压缩至MB)