create table 表名 as select 与 select * into

一、新表不存在

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;

 

posted @ 2020-05-28 10:26  蜕变1  阅读(1524)  评论(0编辑  收藏  举报