复制表数据

一、新表不存在

1、create table cs as select * from t_aly_il_result  ---备份结构和数据

2、create table cs1 as select * from t_aly_il_result where 1 = 0  ---复制结构

3、create table cs2 as select up_inst_id,aly_layer from t_aly_il_result --复制部分字段

二、新表已存在(以下必须先创建表)   

    前提条件:create table cs3 as select * from t_aly_il_result where 1 = 0 --表结构已存在

1、复制数据

select * from cs3 ---没数据的表
insert into cs3 select * from t_aly_il_result; --复制数据到新表

 2、select into new_table from old_table;

3、select into new_table from old_table where 1=2;

原文地址:https://www.cnblogs.com/karlz/p/14442113.html