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;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM